I'm learning Backbone and trying to integrate Firebase via their Backfire extension. I'm following the 'Queries, Part 1' article on
firebase.com which seem pretty clear on their own but.. I'm not too sure how to translate it into a Backbone/Backfire environment.
Let's say I've instantiated a collection of Users:
var UsersCollection = Backbone.Firebase.Collection.extend({
model: UserModel,
});
var Users = new UsersCollection();
...and I have a template rendering the full list, works fine:
var context = { allUsers: Users.toJSON() };
this.$el.html( this.template( context ) );
Now, let's say, in my View I want to filter the collection down to a specific id, or email address, or dates based on some logic, and re-render the template with the result -- a shorter list, or a single record.
To get a single record, I tried doing things like: Users.get(id).toJSON() but the template no longer renders anything (although an object is returned when I log it..)
If I wanted a more complex query on this data, let's say between specific dates, or even the last 10 records, would I need to define and re-instantiate a whole new Collection at this point?? Sorry, coming from Django, just trying to figure out the right way to do it..
Thanks!