Display only select key value pairs from firebase

79 views
Skip to first unread message

JD

unread,
Mar 24, 2015, 12:33:28 AM3/24/15
to fireba...@googlegroups.com
Hello, I have a small like of code which selectively chooses the first two items from firebase with .limitToFirst(2) and I would prefer to have a more organized way of displaying items. I tried .hasClass() but this line of code looks to firebase and there are no classes to be found (obviously). Any suggestions what I might do to have only select keys grabbed from firebase based on which ones contain something like: 

key1 {
         display:"true"
}

Here is the code:

return $firebase( ( new Firebase(dvUrl + '/' + itemType) ).limitToFirst(2) ).$asArray();

Frank van Puffelen

unread,
Mar 24, 2015, 10:43:52 AM3/24/15
to fireba...@googlegroups.com
Hi JD,

It looks like you're trying to build what is known as a Query in Firebase.

var query = new Firebase(dvUrl+'/'+itemType).orderByChild('display').equalTo(true).limitToFirst(2);
return $firebase(query).$asArray(); // or on AngularFire 1.0 and up: return $firebaseArray(query);

Have a look at the section of the development guide on queries too: https://www.firebase.com/docs/web/guide/retrieving-data.html#section-queries .

You should also define an index in your security rules for this to ensure it stays performant with later sets of nodes. See: https://www.firebase.com/docs/security/guide/indexing-data.html

    Frank / puf
Reply all
Reply to author
Forward
0 new messages