i want to do one request same: this.afdb.database.list(’/chat/’, {
query: {
orderByChild: ‘date’,where(idUser===“param”)
}
});
constructor(public afs: AngularFirestore) {}
getUserChat(id) {
return this.afs.collection('chat', ref => ref.where('idUser', '==', id).orderBy('date')).valueChanges();
}
thanks lacOniC but i use real time database can i use AngularFirestore for get data? and is it possible to use 2 conditions like ref.where(‘idUser’, ‘==’, id1 and ‘idUser’, ‘==’, id2)
Firestore is the newest database. If it is possible (new project) use Firestore.
There is no AND but you can use multiple conditions like:
ref.where('idUser', '==', id).where('userName', '==', name)
Yeah thank LacOnic you are the best
hi LacOnic i wanna do some thing like ref.where(‘idUser’, ‘==’, id OR ‘idUser’, ‘==’, id2 ) . how can i do that?
There is no OR operator. To me it’s the biggest missing in Firestore. But in your situation there is no need to OR. You can use IN operator:
ref.where('idUser', 'in', ['123', '456']);
https://firebase.google.com/docs/firestore/query-data/queries#in_and_array-contains-any
Thanks i did it successfuly