DerbyJS get model as array

96 Views Asked by At

I want to be able to get a collection as an array so that I can in the template use {{each}} on it.

It is a collection of users, which are objects, {{each}} doesn't work with objects

2

There are 2 best solutions below

2
rkstedman On BEST ANSWER

Specifically, you can call model.filter() with null for the function, and it will create a list out of all items in the input object. This can be handy as a way to render all subscribed items in a collection, since only arrays can be used as an input to {{each}} template tags.

 var filter = model.filter( model.scope('pants'), null);
 filter.ref('_page.pantsArray');

Here is a link to more details on how to use filters in the derby documentation: http://derbyjs.com/docs/derby-0.6/models/filters-and-sorts

0
carl-johan.blomqvist On

Use filters top convert a collection to an array (which will also stay reactively up to date).