Reputation: 17
I am trying to filter data from firebase query based on some labels
My data is structured like this
projects:
this.filteredProjects$ = af.database.list(path, { query: { orderByChild: 'labels', equalTo: this.filter$ } });
filterProjects(filter: string): void { this.filter$.next(!filter ? null : {value: true, key: filter}); }
And i tried to use this firebase feature: The Firebase SDK supports an optional key parameter for startAt, endAt, and equalTo when ordering by child, value, or priority. You can specify the key parameter using an object literal that contains the value and the key. For example: startAt: { value: 'some-value', key: 'some-key' }.
But I am getting this error: ERROR Error: Query: First argument passed to startAt(), endAt(), or equalTo() cannot be an object.
Upvotes: 1
Views: 1270
Reputation: 52
I was able to do something like this:
af.database.list(path, { query: { orderByChild: 'labels/' + label, equalTo: true } });
where the label
variable is the label name I want to query.
Upvotes: 1