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; })