有没有一种方式可以指定“文档不包含字段”的条件呢?
例如,我想只找到这两个文档中的第一个文档,因为它没有“price”字段。
{"fruit":"apple", "color":"red"}
{"fruit":"banana", "color":"yellow", "price":"2.00"}
有没有一种方式可以指定“文档不包含字段”的条件呢?
例如,我想只找到这两个文档中的第一个文档,因为它没有“price”字段。
{"fruit":"apple", "color":"red"}
{"fruit":"banana", "color":"yellow", "price":"2.00"}
db.mycollection.find({ "price" : null })
。该语句的意思是查询mycollection
集合中所有价格为空的文档。 - evilReiko