# Ionic searchbar list firebase deprecated

**URL:** <https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071>\
**Category:** ionic-v3\
**Created:** [December 21, 2017, 9:33am UTC](https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071 "2017-12-21T09:33:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![flosrn](https://avatars.discourse-cdn.com/v4/letter/f/4491bb/32.png) [@flosrn](https://forum.ionicframework.com/u/flosrn)\
**Post date:** [December 21, 2017, 9:33am UTC](https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071/1 "2017-12-21T09:33:59Z")

</div>

Hello !

In my Ionic Application I would like search users in my firebase database with a searchbar, but the ‘list’ method in ‘AngularFireDatabase’ has changed with the new version.

I found help with the new version of angular firebase here : [https://github.com/angular/angularfire2/blob/HEAD/docs/rtdb/querying-lists.md](https://github.com/angular/angularfire2/blob/HEAD/docs/rtdb/querying-lists.md)

but it does not work…

My code :

**profile-search.component.ts**

```auto
import { Component } from '@angular/core';
import { DataService } from '../../providers/data/data.service';
import { Profile } from "../../models/profile/profile.interface";
import { USER_LIST } from '../../mocks/profiles/profiles';

@Component({
  selector: 'app-profile-search',
  templateUrl: 'profile-search.component.html'
})
export class ProfileSearchComponent {

  query: string;

  profileList: Profile[];

  constructor(private data: DataService) {

  }

  // ! I have an error here ! //
  searchUser(query: string) { // I add '.valueChanges()' because the .subscribes is deprecated
    this.data.searchUser(query).valueChanges().subscribe(profiles => { 
      this.profileList = profiles; // The error is on the 'this.profileList'
    })
  }
}

```

**data.service.ts**

```auto
import { Injectable } from '@angular/core';
import { AngularFireDatabase, AngularFireObject } from "angularfire2/database";
import { Observable } from 'rxjs/Observable';
import { User } from "firebase/app";
import { Profile } from "../../models/profile/profile.interface";
import "rxjs/add/operator/take";

@Injectable()
export class DataService {

  profileObject: AngularFireObject<Profile>

  profileList: Observable<Profile>

  constructor(private database: AngularFireDatabase) {

  }

  getProfile(user: User) {
    this.profileObject = this.database.object(`/profiles/${user.uid}`);
    return this.profileObject;  
  } 

  // The function for search users
  searchUser(firstName: string) {
    const query = this.database.list('/profiles', ref => ref.orderByChild('firstName').equalTo(firstName))
    return query;
  }
}

```

**profile-search.component.html**

```auto
<ion-searchbar [(ngModel)]="query" (ionChange)="searchUser(query)"></ion-searchbar>

<ion-list *ngIf="profileList.length > 0">

  <ion-item *ngFor="let profile of profileList">
    <ion-avatar item-left>
      <img src="assets/img/avatar.png" alt="Avatar">
    </ion-avatar>
    <h2>{{ profile.firstName }} {{profile.lastName }}</h2>
  </ion-item>
</ion-list>

```

**profiles.ts**

```auto
import { Profile } from "../../models/profile/profile.interface";

const userList: Profile[] = [
    { firstName: 'Paul', lastName: 'Halliday', email: 'paul@paul.com', avatar: 'assets/img/avatar.png', dateOfBirth: new Date() },
    { firstName: 'John', lastName: 'Doe', email: 'john@doe.com', avatar: 'assets/img/avatar.png', dateOfBirth: new Date() },
    { firstName: 'Sarah', lastName: 'Conor', email: 'sarah@conor.com', avatar: 'assets/img/avatar.png', dateOfBirth: new Date() },
    { firstName: 'Mr', lastName: 'Dupont', email: 'mr@dupont.com', avatar: 'assets/img/avatar.png', dateOfBirth: new Date() }
];

export const USER_LIST = userList;

```

 ![project](https://global.discourse-cdn.com/ionicframework/original/3X/3/0/30a698b20350c462a16119f6220c33b868604e14.png)

Thank you in advance !

---

<div class="post-metadata">

**Author:** ![FrancoisIonic](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/francoisionic/32/106767_2.png) [@FrancoisIonic](https://forum.ionicframework.com/u/FrancoisIonic)\
**Post date:** [December 21, 2017, 9:47am UTC](https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071/2 "2017-12-21T09:47:30Z")

</div>

Your function looks very well coded, I have no time to check every of it but to degug:

deompose all files in one single fiie  
make sure you have nbginx or apache logs  
sudo service apache or nighix

then come back

---

<div class="post-metadata">

**Author:** ![flosrn](https://avatars.discourse-cdn.com/v4/letter/f/4491bb/32.png) [@flosrn](https://forum.ionicframework.com/u/flosrn)\
**Post date:** [December 21, 2017, 9:51am UTC](https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071/3 "2017-12-21T09:51:30Z")

</div>

Thank you François.

In fact my error is just on my searchUser function :

```auto
searchUser(query: string) { // I add '.valueChanges()' because the .subscribes is deprecated
    this.data.searchUser(query).valueChanges().subscribe(profiles => { 
      this.profileList = profiles; // The error is on the 'this.profileList'
    })
  }

```

---

<div class="post-metadata">

**Author:** ![FrancoisIonic](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/francoisionic/32/106767_2.png) [@FrancoisIonic](https://forum.ionicframework.com/u/FrancoisIonic)\
**Post date:** [December 21, 2017, 9:53am UTC](https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071/4 "2017-12-21T09:53:31Z")

</div>

Well florn it depends, it you have the regular sqlite function it shouldn’t bug.  
Did you enable this in your web server (apache / nghinx).

---

<div class="post-metadata">

**Author:** ![flosrn](https://avatars.discourse-cdn.com/v4/letter/f/4491bb/32.png) [@flosrn](https://forum.ionicframework.com/u/flosrn)\
**Post date:** [December 21, 2017, 10:08am UTC](https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071/5 "2017-12-21T10:08:43Z")

</div>

I don’t konw what you mean… I simply use AngularFireDataBase method but the querying lists has changed, I do not need sqlite function and I don’t use apache or nghinx

---

<div class="post-metadata">

**Author:** ![flosrn](https://avatars.discourse-cdn.com/v4/letter/f/4491bb/32.png) [@flosrn](https://forum.ionicframework.com/u/flosrn)\
**Post date:** [December 21, 2017, 1:18pm UTC](https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071/6 "2017-12-21T13:18:54Z")

</div>

No more help ? Please ☹

---

<div class="post-metadata">

**Author:** ![AaronSterling](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@AaronSterling](https://forum.ionicframework.com/u/AaronSterling)\
**Post date:** [December 21, 2017, 1:22pm UTC](https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071/7 "2017-12-21T13:22:20Z")

</div>

You can import the old API from the legacy library. Look at the AngularFire2 docs, it explains how to do that. You don’t need to change any of your code except the import statement.

---

<div class="post-metadata">

**Author:** ![flosrn](https://avatars.discourse-cdn.com/v4/letter/f/4491bb/32.png) [@flosrn](https://forum.ionicframework.com/u/flosrn)\
**Post date:** [December 21, 2017, 1:49pm UTC](https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071/8 "2017-12-21T13:49:14Z")

</div>

I already try this, when I import :

`import { FirebaseObjectObservable, FirebaseListObservable } from "angularfire2/database-deprecated";`

I still have an error on the .subscribe

---

<div class="post-metadata">

**Author:** ![AaronSterling](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@AaronSterling](https://forum.ionicframework.com/u/AaronSterling)\
**Post date:** [December 21, 2017, 1:50pm UTC](https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071/9 "2017-12-21T13:50:52Z")

</div>

You’re mixing the two APIs. Use one or the other.

---

<div class="post-metadata">

**Author:** ![flosrn](https://avatars.discourse-cdn.com/v4/letter/f/4491bb/32.png) [@flosrn](https://forum.ionicframework.com/u/flosrn)\
**Post date:** [December 21, 2017, 2:07pm UTC](https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071/10 "2017-12-21T14:07:50Z")

</div>

Sorry but it not work… no matter the API I use I have an error on the .subcribe.

When I try to add .valueChanges() before the .subscribe I have an error on the this.profileList

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:57pm UTC](https://forum.ionicframework.com/t/ionic-searchbar-list-firebase-deprecated/116071/11 "2021-07-19T21:57:56Z")

</div>

Closed on July 19, 2021, 9:57pm UTC


