发布于 2015-09-14 14:54:06 | 151 次阅读 | 评论: 0 | 来源: 网络整理

This document contains a list of all operators used with MongoDB in version 2.2.3. See 核心操作(CRUD) for a higher level overview of the operations that use these operators, and 查询, 更新, 投射, 和集合算符 for a more condensed index of these operators.

查询选择器

比较

注解

To express equal to (e.g. =) in the MongoDB query language, use JSON { key:value } structure. Consider the following prototype:

db.collection.find( { field: value } )

For example:

db.collection.find( { a: 42 } )

This query selects all the documents the where the a field holds a value of 42.

You may combine comparison operators to specify ranges:

db.collection.find( { field: { $gt: value1, $lt: value2 } } );

This statement returns all documents with field between value1 and value2.

注解

Fields containing arrays match conditional operators, if only one item matches. Therefore, the following query:

db.collection.find( { field: { $gt:0, $lt:2 } } );

Will match a document that contains the following field:

{ field: [-1,3] }

逻辑

JavaScript

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

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