I have this data structure, where todos are organized to follow path /todos/uid/
{
"metausers" : {
"simplelogin:1" : {
"displayName" : "John Doe",
"provider" : "password",
"provider_id" : "1"
},
"simplelogin:2" : {
"displayName" : "GI Jane",
"provider" : "password",
"provider_id" : "2"
}
},
"todos" : {
"simplelogin:1" : {
"-JUAfv4_-ZUlH7JqM4WZ" : {
"completed" : false,
"done" : false,
"group" : false,
"private" : false,
"subject" : "First"
},
"-JUAfveXP_sqqX32jCJS" : {
"completed" : false,
"done" : false,
"group" : false,
"private" : true,
"subject" : "Second"
},
"-JUAfwXnMo6P53Qz6Fd2" : {
"completed" : false,
"done" : false,
"group" : false,
"private" : false,
"subject" : "Third"
}
},
"simplelogin:2" : {
"-JUAg9rVemiNQykfvvHs" : {
"completed" : false,
"done" : false,
"group" : false,
"private" : false,
"subject" : "Q first"
},
"-JUAgAmgPwZLPr2iH1Ho" : {
"completed" : false,
"done" : false,
"group" : false,
"private" : false,
"subject" : "Q second"
},
"-JUAgBfF8f7V5R5-XgrY" : {
"completed" : false,
"done" : false,
"group" : false,
"private" : true,
"subject" : "Q third"
}
}
}
}
and i would like to query todos to get all records with private:true. Is this possible using firebase (angularfire) and how should i do it ? Or should i denormalize a bit more and arrange path /private to avoid of walking down todos ?
privateproperty is neither of those, you'll have to either promote it to such (e.g. by callingsetPrioritywith the value ofprivatefor each node) or you'll have to provide an index that provides a list of the data by value (e.g. a node with the names of all non-private todo's). See firebase.com/blog/2013-04-12-denormalizing-is-normal.html, firebase.com/blog/2013-10-01-queries-part-one.html and firebase.com/blog/2014-01-02-queries-part-two.html