<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: rikoroku</title>
    <description>The latest articles on DEV Community by rikoroku (@rikoroku).</description>
    <link>https://dev.to/rikoroku</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F420727%2F82065a59-c13a-4ae7-9bdc-7d53630c39df.png</url>
      <title>DEV Community: rikoroku</title>
      <link>https://dev.to/rikoroku</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rikoroku"/>
    <language>en</language>
    <item>
      <title>How to use LIKE operator with AngularFire?</title>
      <dc:creator>rikoroku</dc:creator>
      <pubDate>Thu, 30 Jul 2020 02:24:14 +0000</pubDate>
      <link>https://dev.to/rikoroku/how-to-use-like-operator-with-angularfire-5h41</link>
      <guid>https://dev.to/rikoroku/how-to-use-like-operator-with-angularfire-5h41</guid>
      <description>&lt;p&gt;I will show you a way, what how to use LIKE operator with AngularFire.&lt;/p&gt;

&lt;p&gt;This post is based on &lt;a href="https://stackoverflow.com/questions/46642641/sql-like-operator-in-cloud-firestore"&gt;this&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  ng version
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Angular CLI: 9.0.2
Node: 12.16.0

Package                           Version
-----------------------------------------------------------
@angular-devkit/core              9.0.2
@angular/cli                      9.0.2
@angular/fire                     6.0.0-rc.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  codes
&lt;/h2&gt;

&lt;p&gt;src/app/models/user.model.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export class User {
  id: string;
  name: string;
  createdAt: Date;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;src/app/services/user.service.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Injectable } from "@angular/core";
import { AngularFirestore } from "@angular/fire/firestore";
import { User } from "src/app/models/user.model";

@Injectable()
export class UserService {
  constructor(private firestore: AngularFirestore) {}

  findUsers(name: string) {
    // 'users' is a name of users collection on Firestore
    return this.firestore.collection&amp;lt;User&amp;gt;('users', ref =&amp;gt; { return ref.orderBy('name').startAt(name).endAt(name+'\uf8ff') }).snapshotChanges();
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;src/app/components/user/user.component.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Component, OnInit } from "@angular/core";
import { UserService } from "src/app/services/user.service";

@Component({
  selector: "app-user",
  templateUrl: "./user.component.html",
  styleUrls: ["./user.component.scss"]
})
export class UserComponent implements OnInit {
  constructor(private uService: UserService) {}

  ngOnInit(): void {}

  search() {
    this.uService.findUsers("A part of the user name you want to find").subscribe(data =&amp;gt; {
      console.log(data)
    });
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above codes are now working completely.&lt;/p&gt;

&lt;p&gt;I hope that this post helps you for using LIKE operator with AngularFire.&lt;/p&gt;

&lt;p&gt;If you got some problems. Don't be confused. Please share me with information about errors. I will teach you how to fix it.&lt;/p&gt;

&lt;p&gt;Thank you for reading.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>firestore</category>
    </item>
  </channel>
</rss>
