0

So, we have a contact management system where we store first name, last name and company name. i understand that firebase db cannot do those relational DB style queries using relational operators but is there a creative way to support that search can give results from either if the above 3 attributes.?

As an example:

{
"fName" : "abc",
"lName" : "pqr",
"cName" : "lmn"
},
{
"fName" : "pbc",
"lName" : "aqr",
"cName" : "tmn"
},
{
"fName" : "dbc",
"lName" : "tqr",
"cName" : "amn"
},

The query used currently is:

 this.db.list("/users/" + userKey + "/cards", 
ref => ref.orderByChild('fName').startAt('a').endAt('a' +"\uf8ff") )

With above query it will only return 1st record. What I need is to return all 3 as all 3 has at least one property beginning with 'a'

I think the other suggested tricks on other posts like creating another attribute combining values from other attributes wont work here. As they do a equalTo search.

1 Answer 1

1

With Realtime Database, you can only order and filter on a single child at a time. So, what you're trying to do isn't possible given your current database structure for a single query.

What you can do instead is issue multiple queries, one for each field you want to check, and merge the results of each of those queries on the client.

Sign up to request clarification or add additional context in comments.

1 Comment

yeah that was the only option i thought i have and was looking for any better option. no worries will go with that option

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.