iphone - How to fetch string in particular key in firebase -


i have firebase data below:

chats |  | + - - -simplelogin48simplelogin50 |     |      | + - - simplelogin50simplelogin48  | |      |    + - - -simplelogin48simplelogin50 

now want fetch chat data contains "simplelogin 48". is possible?

no, firebase not support contains operator in queries. firebase provides querystartingatvalue , queryendingatvalue operators selecting range of keys, both based on start of key (or property value or priority if you've ordered on those). see section of firebase ios documentation explains querying.

so by:

[[[[ref queryorderedbykey] querystartingatvalue:@"simplelogin48"] queryendingatvalue:@"simplelogin48"] 

you get:

+ - - -simplelogin48simplelogin50 + - - -simplelogin48simplelogin50 

but not:

+ - - simplelogin50simplelogin48  

the way work around creating so-called index node, in case lists chat ids each user:

chats_by_user   |       + - - simplelogin48   |  |        |  + - - simplelogin48simplelogin50    |  |        |  + - - simplelogin48simplelogin49    |  |        |  + - - simplelogin50simplelogin48    |       + - - simplelogin49   |  |        |  + - - simplelogin48simplelogin49    |       + - - simplelogin50     |          + - - simplelogin50simplelogin48      |          + - - simplelogin48simplelogin50  

with structure can access chats_by_user/simplylogin48 references chats user.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -