Reputation: 97
I would like to perform fairly complex filtering on Marionette Collections. Is there way to search for models with a DB like querys like the MongoDB API?
Example:
MarionetteCollection.find(
{
type: 'product',
$or: [ { qty: { $gt: 100 } }, { price: { $lt: 9.95 } } ],
$and [ { active: true} ],
$sortby{'name'},
$order {'asc'}
});
Maybe an extension to Marionette.js?
Upvotes: 1
Views: 179
Reputation: 1917
Backbone has a simple implementation of what you are asking. Collection.where() && Collection.findWhere() can take an object and will find the model based on your object. But it doesn't more complex matchings like, greater than, less than, etc.
MarionetteCollection.find(
{
type: 'product',
qty: 55,
active: true
});
Upvotes: 0
Reputation: 9426
There is nothing in Marionette
to help you here and Marionette
doesn't make any changes/additions to the regular Backbone.Collection
.
You could take a look at backbone-query
. It appears to do what you are wanting.
Upvotes: 1