我想对Marionette集合执行相当复杂的筛选。有什么方法可以像MongoDB API那样使用类似数据库的查询来搜索模型?
示例:
MarionetteCollection.find(
{
type: 'product',
$or: [ { qty: { $gt: 100 } }, { price: { $lt: 9.95 } } ],
$and [ { active: true} ],
$sortby{'name'},
$order {'asc'}
});也许是Marionette.js的扩展?
发布于 2014-10-23 17:34:59
Marionette中没有任何东西可以帮助您,而且Marionette不会对常规Backbone.Collection进行任何更改/添加。
你可以看看backbone-query。它似乎能做你想做的事。
发布于 2014-10-24 13:23:50
主干有一个简单的实现您所要求的东西。Collection.where() && Collection.findWhere()可以接受一个对象,并根据您的对象找到模型。但它并不是更复杂的比赛,比如,大于,小于,等等。
MarionetteCollection.find(
{
type: 'product',
qty: 55,
active: true
});https://stackoverflow.com/questions/26517870
复制相似问题