文档中心

SequoiaDB 简介

快速入门

安装部署

数据库实例

分布式引擎

SAC 管控中心

SequoiaPerf 性能分析工具

参考手册

常见问题及解答(FAQ)

版本信息

匹配符

匹配符可以指定匹配条件,使查询仅返回符合条件的记录;还可以与函数操作配合使用,以实现更复杂的匹配操作。

匹配符列表如下:

匹配符 描述 示例
$gt 大于 db.sample.employee.find( { age: { $gt: 20 } } )
$gte 大于等于 db.sample.employee.find( { age: { $gte: 20 } } )
$lt 小于 db.sample.employee.find( { age: { $lt: 20 } } )
$lte 小于等于 db.sample.employee.find( { age: { $lte: 20 } } )
$ne 不等于 db.sample.employee.find( { age: { $ne: 20 } } )
$in 集合内存在 db.sample.employee.find( { age: { $in: [ 20, 21 ] } } )
$nin 集合内不存在 db.sample.employee.find( { age: { $nin: [ 20, 21 ] } } )
$all 全部 db.sample.employee.find( { age: { $all: [ 20, 21 ] } } )
$and db.sample.employee.find( { $and: [ { age: 20 }, { name: "Tom" } ] } )
$not db.sample.employee.find( { $not: [ { age: 20 }, { name: "Tom" } ] } )
$or db.sample.employee.find( { $or: [ { age: 20 }, { name: "Tom" } ] } )
$exists 存在 db.sample.employee.find( { age: { $exists: 1 } } )
$elemMatch 元素匹配 db.sample.employee.find( { content: { $elemMatch: { age: 20 } } } )
$+标识符 数组元素匹配 db.sample.employee.find( { "array.$2": 10 } )
$regex 正则表达式 db.sample.employee.find( { str: { $regex: 'dh, * fj', $options:'i' } } )
$mod 取模匹配 db.sample.employee.find( { "age": { "$mod": [ 5, 3 ] } } )
$et 相等匹配 db.sample.employee.find( { "id": { "$et": 1 } } )
$isnull 选择集合中指定字段是否为空或不存在 db.sample.employee.find( { age: { $isnull: 0 } } )

数组属性操作

数组属性操作 描述 示例
$expand 数组展开成多条记录 db.sample.employee.find( { a: { $expand: 1 } } )
$returnMatch 返回匹配的数组元素 db.sample.employee.find( { a: { $returnMatch: 0, $in: [ 1, 4, 7 ] } } )
回到顶部