2011-09-29 110 views
0

编辑:想通了如何查询数组。这些查询是否有效?

如何查询带点概念的对象中的字段?

attributes: 
    colors: 'red' 

collection.findOne {attributes.colors:'red'}, (doc) -> 
    #returns that doc 

回答

1

你需要引用一个点的属性在里面:

collection.findOne 'attributes.colors': 'red', (doc) -> 
    # returns that doc