发布于 2015-09-14 14:59:32 | 173 次阅读 | 评论: 0 | 来源: 网络整理

$exists

Syntax: { field: { $exists: <boolean> } }

$exists selects the documents that contain the field if <boolean> is true. If <boolean> is false, the query only returns the documents that do not contain the field. Documents that contain the field but has the value null are not returned.

MongoDB $exists does not correspond to SQL operator exists. For SQL exists, refer to the $in operator.

Consider the following example:

db.inventory.find( { qty: { $exists: true, $nin: [ 5, 15 ] } } )

This query will select all documents in the inventory collection where the qty field exists and its value does not equal either 5 nor 15.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务