这些查询有效吗?

时间:2011-09-29 03:34:15

标签: javascript mongodb node.js coffeescript

编辑:想出如何查询数组。

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

attributes:
    colors: 'red'

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

1 个答案:

答案 0 :(得分:1)

您需要引用一个带有点的属性:

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