Search through all the records in firebase

27 views
Skip to first unread message

SUBRAMANIYA BHARATHI KANDASAMY

unread,
Apr 27, 2016, 12:15:52 PM4/27/16
to Firebase Google Group
Hi all,
I have a problem in firebase. the structure of my firebase app is in the screenshot added. What I need to do is to enter user data and search through all the record s and checks whether the entered data is already present or not.  If present update the record with entered data if it is not present then create a new record with the entered data. Kindly help. i am really stuck. 
Untitled.png

Marty Nelson

unread,
Apr 28, 2016, 11:40:19 AM4/28/16
to Firebase Google Group
That's normally what id's are for, so you can determine identity without looking at every property.

But if you really need to do this you could create a string hash of the key value pairs, replace any unsupported characters (see fb docs) and create a node for storing the link between hash and id. Total hash would be need to be less than 768 bytes, so you might need to use a checksum if data too big.

So if you had:

+ things
    + key123
        + name: 'bob'
        + age: 12
        + color: 'blue'
    + key456
        + name: 'jill'
        + age: 14
        + color: 'red'

Then you'd also have:

+ lookup
    + name:bob;age:12;color:blue: key123
    + name:jill;age:14:color:red: key 456
Reply all
Reply to author
Forward
0 new messages