Angular application using AngularFire2. I'm attempting to query firebase on a child object, rather than just a child string property. Querying by the child string property works, but how can I query by the entire object.
This code works
// Given the following firebase data structure
httpCache: {
{ID}: {
url: 'www.fakeurl',
otherProperties: {}
}
}
// This code will return results if exists where the url matches
this.af.database.list('httpCache', {
query: {
orderByChild: 'url',
equalTo: 'www.fakeurl'
}
}).subscribe(x => {
if (x.length > 0) { console.log('match found!'); }
});
This code does not work:
// Given the following firebase data structure
httpCache: {
{ID}: {
request: {
url: 'www.fakeurl',
params: 'id=1'
},
otherProperties: {}
}
}
// This code throws an exception
let request = {
url: 'www.fakeurl',
params: 'id=1'
};
this.af.database.list('httpCache', {
query: {
orderByChild: 'request',
equalTo: request
}
}).subscribe(x => {
if (x.length > 0) { console.log('match found!'); }
});
Here is the exception:
Query: First argument passed to startAt(), endAt(), or equalTo() cannot be an object.
I'm attempting to use the 2nd solution shown here where the filter criteria is pushed into a child object containing all filter properties: Query based on multiple where clauses in firebase