0

我有集合名称@collection。 @collection的每个模型是这样的:如何使用.where()查询骨干模型的嵌套对象

{ 
name : "example", 
layout : { 
    x : 100, 
    y : 100, 
    } 
} 

我要做找到模式,使 model.attributes.layout[x] == '100'

我可以做这样的事吗@collection.where({layout[x] :100})?或者还有其他方法可以做这种查询吗?

回答

1

filter使用方法

collection.filter(function(model) { return model.get('layout).x === 100; })