- MongoDB官方文档中文版
 - MongoDB用户手册
 - MongoDB简介
 -  安装 MongoDB   
- 安装MongoDB社区版
 - 安装MongoDB企业版
 - 将社区版MongoDB升级到企业版MongoDB
 - 验证MongoDB软件包的完整性
 
 - Mongo Shell
 - 增删改查操作
 - 聚合
 -  数据模式   
- 数据建模介绍
 - 模式验证
 - Data Modeling Concepts
 -  Data Model Examples and Patterns   
- Model Relationships Between Documents
 - Model One-to-One Relationships with Embedded Documents
 - Model One-to-Many Relationships with Embedded Documents
 - Model One-to-Many Relationships with Document References
 - Model Tree Structures
 - Model Tree Structures with Parent References
 - Model Tree Structures with Child References
 - Model Tree Structures with an Array of Ancestors
 - Model Tree Structures with Materialized Paths
 - Model Tree Structures with Nested Sets
 - Model Specific Application Contexts
 - Model Data for Atomic Operations
 - Model Data to Support Keyword Search
 - Model Data for Schema Versioning
 - Model Monetary Data
 - Model Time Data
 - Model Computed Data
 
 - Data Model Reference
 
 - 事务
 -  索引   
- Single Field Indexes
 - Compound Indexes
 - Multikey Indexes
 - Text Indexes
 - Wildcard Indexes
 - 2dsphere Indexes
 - 2d Indexes
 - geoHaystack Indexes
 - Hashed Indexes
 - 索引特性
 - Index Builds on Populated Collections
 - 索引交集
 - Manage Indexes
 - 衡量索引使用
 - Indexing Strategies
 - Indexing Reference
 - 2d索引
 - 2dsphere索引
 - 复合索引
 - geoHaystack索引
 - Hashed 索引
 - 在填充的集合上建立索引
 - 索引参考
 - 索引策略
 - 管理索引
 - 多键索引
 - 单字段索引
 - 文本索引
 - 通配符索引
 
 -  安全   
- 安全检查列表
 - Enable Access Control
 -  身份验证   
- Users
 - Add Users
 - Authentication Mechanisms
 - SCRAM
 - x.509
 - Enterprise Authentication Mechanisms
 - Kerberos Authentication
 - LDAP Proxy Authentication
 - LDAP Authorization
 - Internal/Membership Authentication
 - Deploy Replica Set With Keyfile Authentication
 - Update Replica Set to Keyfile Authentication
 - Update Replica Set to Keyfile Authentication (No Downtime)
 - Rotate Keys for Replica Sets
 - Deploy Sharded Cluster with Keyfile Authentication
 - Update Sharded Cluster to Keyfile Authentication
 - Update Sharded Cluster to Keyfile Authentication (No Downtime)
 - Rotate Keys for Sharded Clusters
 - Use x.509 Certificate for Membership Authentication
 - Upgrade from Keyfile Authentication to x.509 Authentication
 - Rolling Update of x.509 Cluster Certificates that Contain New DN
 
 - Role-Based Access Control
 - TLS/SSL (Transport Encryption)
 - Encryption at Rest
 - Client-Side Field Level Encryption
 - 审计
 - Network and Configuration Hardening
 - Implement Field Level Redaction
 - Security Reference
 - Create a Vulnerability Report
 - Appendix
 - 附录
 - 启用访问控制
 - 网络和配置强化
 - 安全参考
 
 - 改变流
 -  复制集   
- 复制集成员
 - 副本集日志
 - Replica Set Data Synchronization
 - 副本集部署架构
 - Replica Set High Availability
 - Replica Set Read and Write Semantics
 - Replica Set Deployment Tutorials
 - Member Configuration Tutorials
 -  Replica Set Maintenance Tutorials   
- Change the Size of the Oplog
 - Perform Maintenance on Replica Set Members
 - Force a Member to Become Primary
 - Resync a Member of a Replica Set
 - Configure Replica Set Tag Sets
 - Reconfigure a Replica Set with Unavailable Members
 - Manage Chained Replication
 - Change Hostnames in a Replica Set
 - Configure a Secondary’s Sync Target
 
 - Replication Reference
 - 副本集数据同步
 
 -  分片   
- 分片集群组成]
 - 片键
 - 哈希分片
 - 范围分片
 - 部署分片集群
 - 区域
 - Data Partitioning with Chunks
 - Balancer
 -  Administration   
- Config Server Administration
 - Replace a Config Server
 - View Cluster Configuration
 - Restart a Sharded Cluster
 - Migrate a Sharded Cluster to Different Hardware
 - Add Shards to a Cluster
 - Remove Shards from an Existing Sharded Cluster
 - Clear jumbo Flag
 - Back Up Cluster Metadata
 - Convert Sharded Cluster to Replica Set
 - Convert a Replica Set to a Sharded Cluster
 - Convert a Shard Standalone to a Shard Replica Set
 
 - Sharding Reference
 - 分片键
 - Zone
 
 -  管理权限   
- 产品说明
 - Operations Checklist
 - Development Checklist
 - Performance
 - 配置和维护
 - Data Center Awareness
 -  MongoDB Backup Methods   
- Back Up and Restore with Filesystem Snapshots
 - Back Up and Restore with MongoDB Tools
 - Restore a Replica Set from MongoDB Backups
 - Backup and Restore Sharded Clusters
 - Back Up a Sharded Cluster with File System Snapshots
 - Back Up a Sharded Cluster with Database Dumps
 - Schedule Backup Window for Sharded Clusters
 - Restore a Sharded Cluster
 - Recover a Standalone after an Unexpected Shutdown
 
 - Monitoring for MongoDB
 - 开发检查表
 - MogoDB 备份方法
 - 操作检查表
 - MongoDB性能
 
 - 存储
 - 常见问题
 -  参考   
-  Operators   
- Query and Projection Operators
 - Comparison Query Operators
 - Logical Query Operators
 - Element Query Operators
 - Evaluation Query Operators
 - Geospatial Query Operators
 - Array Query Operators
 - Bitwise Query Operators
 - $comment
 - 查询与映射运算符
 - 更新运算符
 - Field Update Operators
 - Array Update Operators
 - Bitwise Update Operator
 - Aggregation Pipeline Stages
 - $addFields (aggregation)
 - $bucket (aggregation)
 - $bucketAuto (aggregation)
 - $collStats (aggregation)
 - $count (aggregation)
 - $currentOp (aggregation)
 - $facet (aggregation)
 - $geoNear (aggregation)
 - $graphLookup (aggregation)
 - $group (aggregation)
 - $indexStats (aggregation)
 - $limit (aggregation)
 - $listLocalSessions
 - $listSessions
 - $lookup (aggregation)
 - $match (aggregation)
 - $merge (aggregation)
 - $out (aggregation)
 - $planCacheStats
 - $project (aggregation)
 - $redact (aggregation)
 - $replaceRoot (aggregation)
 - $replaceWith (aggregation)
 - $sample (aggregation)
 - $set (aggregation)
 - $skip (aggregation)
 - $sort (aggregation)
 - $sortByCount (aggregation)
 - $unionWith (aggregation)
 - $unset (aggregation)
 - $unwind (aggregation)
 - Aggregation Pipeline Operators
 - $sin (aggregation)
 - $abs (aggregation)
 - $slice (aggregation)
 - $accumulator (aggregation)
 - $split (aggregation)
 - $acos (aggregation)
 - $sqrt (aggregation)
 - $acosh (aggregation)
 - $add (aggregation)
 - $addToSet (aggregation)
 - $allElementsTrue (aggregation)
 - $and (aggregation)
 - $anyElementTrue (aggregation)
 - $arrayElemAt (aggregation)
 - $arrayToObject (aggregation)
 - $asin (aggregation)
 - $asinh (aggregation)
 - $sum (aggregation)
 - $atan (aggregation)
 - $atan2 (aggregation)
 - $tan (aggregation)
 - $atanh (aggregation)
 - $avg (aggregation)
 - $binarySize (aggregation)
 - $bsonSize (aggregation)
 - $ceil (aggregation)
 - $toInt (aggregation)
 - $cmp (aggregation)
 - $concat (aggregation)
 - $concatArrays (aggregation)
 - $cond (aggregation)
 - $convert (aggregation)
 - $cos (aggregation)
 - $dateFromParts (aggregation)
 - $dateToParts (aggregation)
 - $type (aggregation)
 - $dateFromString (aggregation)
 - $week (aggregation)
 - $dateToString (aggregation)
 - $year (aggregation)
 - $dayOfMonth (aggregation)
 - $zip (aggregation)
 - $dayOfWeek (aggregation)
 - $dayOfYear (aggregation)
 - $degreesToRadians (aggregation)
 - $divide (aggregation)
 - $eq (aggregation)
 - $exp (aggregation)
 - $filter (aggregation)
 - $first (aggregation accumulator)
 - $first (aggregation)
 - $floor (aggregation)
 - $function (aggregation)
 - $gt (aggregation)
 - $gte (aggregation)
 - $hour (aggregation)
 - $ifNull (aggregation)
 - $in (aggregation)
 - $indexOfArray (aggregation)
 - $indexOfBytes (aggregation)
 - $indexOfCP (aggregation)
 - $isArray (aggregation)
 - $isNumber (aggregation)
 - $isoDayOfWeek (aggregation)
 - $isoWeek (aggregation)
 - $isoWeekYear (aggregation)
 - $last (aggregation accumulator)
 - $last (aggregation)
 - $let (aggregation)
 - $literal (aggregation)
 - $ln (aggregation)
 - $log (aggregation)
 - $log10 (aggregation)
 - $lt (aggregation)
 - $lte (aggregation)
 - $trim (aggregation)
 - $map (aggregation)
 - $max (aggregation)
 - $mergeObjects (aggregation)
 - $meta
 - $min (aggregation)
 - $millisecond (aggregation)
 - $minute (aggregation)
 - $mod (aggregation)
 - $month (aggregation)
 - $multiply (aggregation)
 - $ne (aggregation)
 - $not (aggregation)
 - $objectToArray (aggregation)
 - $or (aggregation)
 - $pow (aggregation)
 - $push (aggregation)
 - $radiansToDegrees (aggregation)
 - $range (aggregation)
 - $reduce (aggregation)
 - $regexFind (aggregation)
 - $regexFindAll (aggregation)
 - $regexMatch (aggregation)
 - $replaceOne (aggregation)
 - $replaceAll (aggregation)
 - $reverseArray (aggregation)
 - $round (aggregation)
 - $rtrim (aggregation)
 - $second (aggregation)
 - $setDifference (aggregation)
 - $setEquals (aggregation)
 - $setIntersection (aggregation)
 - $setIsSubset (aggregation)
 - $setUnion (aggregation)
 - $size (aggregation)
 - $slice (aggregation)
 - $split (aggregation)
 - $sqrt (aggregation)
 - $stdDevPop (aggregation)
 - $stdDevSamp (aggregation)
 - $strcasecmp (aggregation)
 - $strLenBytes (aggregation)
 - $strLenCP (aggregation)
 - $substr (aggregation)
 - $substrBytes (aggregation)
 - $substrCP (aggregation)
 - $subtract (aggregation)
 - $sum (aggregation)
 - $switch (aggregation)
 - $tan (aggregation)
 - $toBool (aggregation)
 - $toDate (aggregation)
 - $toDecimal (aggregation)
 - $toDouble(aggregation)
 - $toInt (aggregation)
 - $toLong (aggregation)
 - $toObjectId (aggregation)
 - $toString (aggregation)
 - $toLower (aggregation)
 - $toUpper (aggregation)
 - $trim (aggregation)
 - $trunc (aggregation)
 - $type (aggregation)
 - $week (aggregation)
 - $year (aggregation)
 - $zip (aggregation)
 - 查询修饰符
 - $comment
 - $explain
 - $hint
 - $max
 - $maxTimeMS
 - $min
 - $orderby
 - $query
 - $returnKey
 - $showDiskLoc
 - $natural
 - 聚合管道操作符
 - $abs (aggregation)
 - $acos (aggregation)
 - $acosh (aggregation)
 - $add (aggregation)
 - $addToSet (aggregation)
 - $and (aggregation)
 - $anyElementTrue (aggregation)
 - $arrayElemAt (aggregation)
 - $arrayToObject (aggregation)
 - $asin (aggregation)
 - $asinh (aggregation)
 - $atan (aggregation)
 - $atan2 (aggregation)
 - $atanh (aggregation)
 - $avg (aggregation)
 - $ceil (aggregation)
 - $cmp (aggregation)
 - $concat (aggregation)
 - $concatArrays (aggregation)
 - $cond (aggregation)
 - $convert (aggregation)
 - $cos (aggregation)
 - $dateFromParts (aggregation)
 - $dateFromString (aggregation)
 - $dateToParts (aggregation)
 - $dateToString (aggregation)
 - $literal (aggregation)
 - 聚合管道阶段
 
 -  数据库命令   
- Aggregation Commands
 - aggregate
 - count
 - distinct
 - mapReduce
 - Geospatial Commands
 - geoSearch
 - Query and Write Operation Commands
 - delete
 - find
 - findAndModify
 - getLastError
 - getMore
 - insert
 - resetError
 - update
 - 查询计划缓存命令
 - planCacheClear
 - planCacheClearFilters
 - planCacheListFilters
 - planCacheSetFilter
 - 认证命令
 - authenticate
 - getnonce
 - logout
 - User Management Commands
 - createUser
 - dropAllUsersFromDatabase
 - dropUser
 - grantRolesToUser
 - revokeRolesFromUser
 - updateUser
 - usersInfo
 - Role Management Commands
 - createRole
 - dropRole
 - dropAllRolesFromDatabase
 - grantPrivilegesToRole
 - grantRolesToRole
 - invalidateUserCache
 - revokePrivilegesFromRole
 - revokeRolesFromRole
 - rolesInfo
 - updateRole
 - Replication Commands
 - applyOps
 - isMaster
 - replSetAbortPrimaryCatchUp
 - replSetFreeze
 - replSetGetConfig
 - replSetGetStatus
 - replSetInitiate
 - replSetMaintenance
 - replSetReconfig
 - replSetResizeOplog
 - replSetStepDown
 - replSetSyncFrom
 - Sharding Commands
 - addShard
 - addShardToZone
 - balancerCollectionStatus
 - balancerStart
 - balancerStatus
 - balancerStop
 - checkShardingIndex
 - clearJumboFlag
 - cleanupOrphaned
 - enableSharding
 - flushRouterConfig
 - getShardMap
 - getShardVersion
 - isdbgrid
 - listShards
 - medianKey
 - moveChunk
 - movePrimary
 - mergeChunks
 - refineCollectionShardKey
 - removeShard
 - removeShardFromZone
 - setShardVersion
 - shardCollection
 - shardingState
 - split
 - splitChunk
 - splitVector
 - unsetSharding
 - updateZoneKeyRange
 - Sessions Commands
 - abortTransaction
 - commitTransaction
 - endSessions
 - killAllSessions
 - killAllSessionsByPattern
 - killSessions
 - refreshSessions
 - startSession
 - Administration Commands
 - cloneCollectionAsCapped
 - collMod
 - compact
 - connPoolSync
 - convertToCapped
 - create
 - createIndexes
 - currentOp
 - drop
 - dropDatabase
 - dropConnections
 - dropIndexes
 - filemd5
 - fsync
 - fsyncUnlock
 - getDefaultRWConcern
 - getParameter
 - killCursors
 - killOp
 - listCollections
 - listDatabases
 - listIndexes
 - logRotate
 - reIndex
 - renameCollection
 - setFeatureCompatibilityVersion
 - setIndexCommitQuorum
 - setParameter
 - setDefaultRWConcern
 - shutdown
 - Diagnostic Commands
 - availableQueryOptions
 - buildInfo
 - collStats
 - connPoolStats
 - connectionStatus
 - cursorInfo
 - dataSize
 - dbHash
 - dbStats
 - diagLogging
 - driverOIDTest
 - explain
 - features
 - getCmdLineOpts
 - getLog
 - hostInfo
 - isSelf
 - listCommands
 - lockInfo
 - netstat
 - ping
 - profile
 - serverStatus
 - shardConnPoolStats
 - top
 - validate
 - whatsmyuri
 - 免费监控命令
 - getFreeMonitoringStatus
 - setFreeMonitoring
 - 数据库命令
 - logApplicationMessage
 - 管理命令
 - 聚合命令
 - 诊断命令
 - 地理空间命令
 - 查询和写操作命令
 - 复制命令
 - 角色管理命令
 - 会话命令
 - 分片命令
 - 用户管理命令
 
 -  mongo Shell 方法   
- Collection Methods
 - db.collection.aggregate()
 - db.collection.bulkWrite()
 - db.collection.copyTo()
 - db.collection.count()
 - db.collection.countDocuments()
 - db.collection.estimatedDocumentCount()
 - db.collection.createIndex()
 - db.collection.createIndexes()
 - db.collection.dataSize()
 - db.collection.deleteOne()
 - db.collection.deleteMany()
 - db.collection.distinct()
 - db.collection.drop()
 - db.collection.dropIndex()
 - db.collection.dropIndexes()
 - db.collection.ensureIndex()
 - db.collection.explain()
 - db.collection.find()
 - db.collection.findAndModify()
 - db.collection.findOne()
 - db.collection.findOneAndDelete()
 - db.collection.findOneAndReplace()
 - db.collection.findOneAndUpdate()
 - db.collection.getIndexes()
 - db.collection.getShardDistribution()
 - db.collection.getShardVersion()
 - db.collection.hideIndex()
 - db.collection.insert()
 - db.collection.insertOne()
 - db.collection.insertMany()
 - db.collection.isCapped()
 - db.collection.latencyStats()
 - db.collection.mapReduce()
 - db.collection.reIndex()
 - db.collection.remove()
 - db.collection.renameCollection()
 - db.collection.replaceOne()
 - db.collection.save()
 - db.collection.stats()
 - db.collection.storageSize()
 - db.collection.totalIndexSize()
 - db.collection.totalSize()
 - db.collection.unhideIndex()
 - db.collection.update()
 - db.collection.updateOne()
 - db.collection.updateMany()
 - db.collection.watch()
 - db.collection.validate()
 - Cursor Methods
 - cursor.addOption()
 - cursor.allowDiskUse()
 - cursor.allowPartialResults()
 - cursor.batchSize()
 - cursor.close()
 - cursor.isClosed()
 - cursor.collation()
 - cursor.comment()
 - cursor.count()
 - cursor.explain()
 - cursor.forEach()
 - cursor.hasNext()
 - cursor.hint()
 - cursor.isExhausted()
 - cursor.itcount()
 - cursor.limit()
 - cursor.map()
 - cursor.max()
 - cursor.maxTimeMS()
 - cursor.min()
 - cursor.next()
 - cursor.noCursorTimeout()
 - cursor.objsLeftInBatch()
 - cursor.pretty()
 - cursor.readConcern()
 - cursor.readPref()
 - cursor.returnKey()
 - cursor.showRecordId()
 - cursor.size()
 - cursor.skip()
 - cursor.sort()
 - cursor.tailable()
 - cursor.toArray()
 - Database Methods
 - db.adminCommand()
 - db.aggregate()
 - db.cloneDatabase()
 - db.commandHelp()
 - db.copyDatabase()
 - db.createCollection()
 - db.createView()
 - db.currentOp()
 - db.dropDatabase()
 - db.eval()
 - db.fsyncLock()
 - db.fsyncUnlock()
 - db.getCollection()
 - db.getCollectionInfos()
 - db.getCollectionNames()
 - db.getLastError()
 - db.getLastErrorObj()
 - db.getLogComponents()
 - db.getMongo()
 - db.getName()
 - db.getProfilingLevel()
 - db.getProfilingStatus()
 - db.getReplicationInfo()
 - db.getSiblingDB()
 - db.help()
 - db.hostInfo()
 - db.isMaster()
 - db.killOp()
 - db.listCommands()
 - db.logout()
 - db.printCollectionStats()
 - db.printReplicationInfo()
 - db.printShardingStatus()
 - db.printSlaveReplicationInfo()
 - db.resetError()
 - db.runCommand()
 - db.serverBuildInfo()
 - db.serverCmdLineOpts()
 - db.serverStatus()
 - db.setLogLevel()
 - db.setProfilingLevel()
 - db.shutdownServer()
 - db.stats()
 - db.version()
 - db.watch()
 - Query Plan Cache Methods
 - db.collection.getPlanCache()
 - PlanCache.clear()
 - PlanCache.clearPlansByQuery()
 - PlanCache.help()
 - PlanCache.list()
 - Bulk Operation Methods
 - db.collection.initializeOrderedBulkOp()
 - db.collection.initializeUnorderedBulkOp()
 - Bulk()
 - Bulk.execute()
 - Bulk.find()
 - Bulk.find.arrayFilters()
 - Bulk.find.collation()
 - Bulk.find.hint()
 - Bulk.find.remove()
 - Bulk.find.removeOne()
 - Bulk.find.replaceOne()
 - Bulk.find.updateOne()
 - Bulk.find.update()
 - Bulk.find.upsert()
 - Bulk.getOperations()
 - Bulk.insert()
 - Bulk.tojson()
 - Bulk.toString()
 - User Management Methods
 - db.auth()
 - db.changeUserPassword()
 - db.createUser()
 - db.dropUser()
 - db.dropAllUsers()
 - db.getUser()
 - db.getUsers()
 - db.grantRolesToUser()
 - db.removeUser()
 - db.revokeRolesFromUser()
 - db.updateUser()
 - passwordPrompt()
 - Role Management Methods
 - db.createRole()
 - db.dropRole()
 - db.dropAllRoles()
 - db.getRole()
 - db.getRoles()
 - db.grantPrivilegesToRole()
 - db.revokePrivilegesFromRole()
 - db.grantRolesToRole()
 - db.revokeRolesFromRole()
 - db.updateRole()
 - Replication Methods
 - rs.add()
 - rs.addArb()
 - rs.conf()
 - rs.freeze()
 - rs.help()
 - rs.initiate()
 - rs.printReplicationInfo()
 - rs.printSlaveReplicationInfo()
 - rs.reconfig()
 - rs.remove()
 - rs.status()
 - rs.stepDown()
 - rs.syncFrom()
 - Sharding Methods
 - sh.addShard()
 - sh.addShardTag()
 - sh.addShardToZone()
 - sh.addTagRange()
 - sh.balancerCollectionStatus()
 - sh.disableBalancing()
 - sh.enableBalancing()
 - sh.disableAutoSplit
 - sh.enableAutoSplit
 - sh.enableSharding()
 - sh.getBalancerHost()
 - sh.getBalancerState()
 - sh.removeTagRange()
 - sh.removeRangeFromZone()
 - sh.help()
 - sh.isBalancerRunning()
 - sh.moveChunk()
 - sh.removeShardTag()
 - sh.removeShardFromZone()
 - sh.setBalancerState()
 - sh.shardCollection()
 - sh.splitAt()
 - sh.splitFind()
 - sh.startBalancer()
 - sh.status()
 - sh.stopBalancer()
 - sh.waitForBalancer()
 - sh.waitForBalancerOff()
 - sh.waitForPingChange()
 - sh.updateZoneKeyRange()
 - convertShardKeyToHashed
 - Free Monitoring Methods
 - db.disableFreeMonitoring()
 - db.enableFreeMonitoring()
 - db.getFreeMonitoringStatus
 - Object Constructors and Methods
 - BulkWriteResult()
 - Date()
 - ObjectId
 - ObjectId.getTimestamp()
 - ObjectId.toString()
 - ObjectId.valueOf()
 - UUID()
 - WriteResult()
 - WriteResult.hasWriteError()
 - WriteResult.hasWriteConcernError()
 - Connection Methods
 - connect()
 - Mongo()
 - Mongo.getDB()
 - Mongo.getReadPrefMode()
 - Mongo.getReadPrefTagSet()
 - Mongo.isCausalConsistency()
 - Mongo.setCausalConsistency()
 - Mongo.setReadPref()
 - Mongo.startSession()
 - Mongo.watch()
 - Session
 - SessionOptions
 - Native Methods
 - cat()
 - cd()
 - copyDbpath()
 - getHostName()
 - getMemInfo()
 - hostname()
 - isInteractive()
 - listFiles()
 - load()
 - ls()
 - md5sumFile()
 - mkdir()
 - pwd()
 - quit()
 - removeFile()
 - resetDbpath()
 - sleep()
 - setVerboseShell()
 - version()
 - _isWindows()
 - _rand()
 - Client-Side Field Level Encryption Methods
 - getKeyVault()
 - KeyVault.createKey()
 - KeyVault.deleteKey()
 - KeyVault.getKey()
 - KeyVault.getKeys()
 - KeyVault.addKeyAlternateName()
 - KeyVault.removeKeyAlternateName()
 - KeyVault.getKeyByAltName()
 - getClientEncryption()
 - ClientEncryption.encrypt()
 - ClientEncryption.decrypt()
 - mongo Shell 方法
 
 - MongoDB Package Components
 - Configuration File Options
 - MongoDB Server Parameters
 - MongoDB Limits and Thresholds
 - Explain Results
 - System Collections
 - 连接字符串URI格式
 - 排序
 - MongoDB的Wire协议
 - 日志消息
 - Exit Codes and Statuses
 - 词汇表
 - 默认的MongoDB端口
 - Default MongoDB Read Concerns/Write Concerns
 - 服务器会话
 - Configuration File Options
 - 默认的MongoDB读/写关注
 - 退出代码和状态
 - MongoDB Limits and Thresholds
 
 -  Operators   
 -  更新说明   
- Release Notes for MongoDB 4.4
 - Release Notes for MongoDB 4.2
 - Release Notes for MongoDB 4.0
 - Release Notes for MongoDB 3.6
 - Release Notes for MongoDB 3.4
 - Release Notes for MongoDB 3.2
 - Release Notes for MongoDB 3.0
 - Release Notes for MongoDB 2.6
 - Release Notes for MongoDB 2.4
 - Release Notes for MongoDB 2.2
 - Release Notes for MongoDB 2.0
 - Release Notes for MongoDB 1.8
 - Release Notes for MongoDB 1.6
 - Release Notes for MongoDB 1.4
 - Release Notes for MongoDB 1.2.x
 - MongoDB Versioning
 
 - 技术支持
 - 开始使用MongoDB开发
 - 联系我们
 - 更多资料
 - 本书使用 GitBook 发布
 
聚合管道操作符
注意:
有关特定运算符的详细信息,包括语法和示例,请单击特定运算符以转到其参考页。
表达式运算符
在这个部分
- 算术表达式运算符
 - 列表表达式运算符
 - 布尔表达式运算符
 - 比较表达式运算符
 - 条件表达式运算符
 - 日期表达式运算符
 - 文字表达式运算符
 - 对象表达式运算符
 - 集合表达式运算符
 - 字符串表达式运算符
 - 文本表达式运算符
 - 三角表达式运算符
 - 类型表达式运算符
 - 累加器($group)
 - 累加器(处于其他阶段)
 - 变量表达式运算符
 
运算符表达式类似于带有参数的函数。通常,这些表达式采用参数数组并具有以下形式:
{ <operator>: [ <argument1>, <argument2> ... ] }
如果 operator 接受单个参数,可以省略指定参数列表的外部数组:
{ <operator>: <argument> }
为了避免在参数是文字数组的情况下解析歧义,必须将文字数组包装在$literal表达式中,或者保留指定参数列表的外部数组。
算术表达式运算符
算术表达式对 numbers 执行数学运算。一些算术表达式也可以支持 date 算术。
| 名称 | 描述 | 
|---|---|
| $abs | 返回数字的绝对 value。 | 
| $add | 添加 numbers 以 return 总和,或添加 numbers 和 date 以 return 新的 date。如果添加 numbers 和 date,则将 numbers 视为毫秒。接受任意数量的参数表达式,但最多只能有一个表达式解析为 date。 | 
| $ceil | 返回大于或等于指定数字的最小 integer。 | 
| $divide | 返回将第一个数除以第二个数的结果。接受两个参数表达式。 | 
| $exp | 将 e 提高到指定的指数。 | 
| $floor | 返回小于或等于指定数字的最大 integer。 | 
| $ln | 计算数字的自然 log。 | 
| $log | 计算指定基数中的数字的 log。 | 
| $log10 | 计算数字的 log 基数 10。 | 
| $mod | 返回第一个数字的余数除以第二个数字。接受两个参数表达式。 | 
| $multiply | 将 numbers 乘以_return 产品。接受任意数量的参数表达式。 | 
| $pow | 将数字提高到指定的指数。 | 
| $round | 将数字四舍五入为整数或指定的小数位。 | 
| $sqrt | 计算平方根。 | 
| $subtract | 返回从第一个中减去第二个 value 的结果。如果这两个值是 numbers,返回差异。如果这两个值是日期,则返回差异(以毫秒为单位)。如果这两个值是 date 和一个以毫秒为单位的数字,_return 结果 date。接受两个参数表达式。如果这两个值是 date 和数字,请首先指定 date 参数,因为从数字中减去 date 没有意义。 | 
| $trunc | 截断其整数的数字。 | 
列表表达式运算符
| 名称 | 描述 | 
|---|---|
| $arrayElemAt | 返回指定的数组索引处的元素。 | 
| $arrayToObject | 将键值对的数组转换为文档。 | 
| $concatArrays | 连接数组以返回连接的数组。 | 
| $filter | 选择数组的子集以返回仅包含与过滤条件匹配的元素的数组。 | 
| $in | 返回一个布尔值,指示指定的值是否在数组中。 | 
| $indexOfArray | 在数组中搜索指定值的出现,并返回第一个出现的数组索引。如果未找到子字符串,则返回-1。 |  
| $isArray | 确定操作数是否为数组。返回一个布尔值。 | 
| $map | 对数组的每个元素应用子表达式,并按顺序返回结果值的数组。接受命名参数。 | 
| $objectToArray | 将文档转换为代表键值对的文档数组。 | 
| $range | 根据用户定义的输入输出包含整数序列的数组。 | 
| $reduce | 将表达式应用于数组中的每个元素,并将它们组合为单个值。 | 
| $reverseArray | 返回具有相反顺序元素的数组。 | 
| $size | 返回数组中元素的数量。接受单个表达式作为参数。 | 
| $slice | 返回数组的子集。 | 
| $zip | 合并两个数组。 | 
布尔表达式运算符
布尔表达式将其参数表达式计算为布尔值,并返回布尔值作为结果。
除了false布尔值,布尔表达式为false如下:null,0,和undefined 的值。布尔表达式将所有其他值评估为true,包括非零数字值和数组。
| 名称 | 描述 | 
|---|---|
| $and | 仅当其所有表达式求值为true时才返回true。接受任意数量的参数表达式。 |  
| $not | 返回与其参数表达式相反的 boolean value。接受单个参数表达式。 | 
| $or | 当任何表达式求值为true时返回true。接受任意数量的参数表达式。 |  
比较表达式运算符
比较表达式返回一个布尔值,但$cmp返回一个数字。
比较表达式采用两个参数表达式并比较 value 和 type,使用指定的 BSON 比较顺序表示不同类型的值。
| 名称 | 描述 | 
|---|---|
| $cmp | 如果两个值相等则返回0,如果第一个 value 大于第二个值则返回1,如果第一个 value 小于第二个值,则返回-1。 |  
| $eq | 如果值相等,则返回true。 |  
| $gt | 如果第一个 value 大于第二个,则返回true。 |  
| $gte | 如果第一个 value 大于或等于第二个,则返回true。 |  
| $lt | 如果第一个 value 小于第二个,则返回true。 |  
| $lte | 如果第一个 value 小于或等于第二个值,则返回true。 |  
| $ne | 如果值不相等,则返回true。 |  
条件表达式运算符
| 名称 | 描述 | 
|---|---|
| $cond | 一个三元运算符,它计算一个表达式,并根据结果返回另外两个表达式之一的值。接受有序列表中的三个表达式或三个命名参数。 | 
| $ifNull | 如果第一个表达式导致结果为null ,则返回第一个表达式的非空结果或第二个表达式的结果。空结果包含未定义值或缺少字段的实例。接受两个表达式作为参数。第二个表达式的结果可以为 null。 | 
| $switch | 计算一系列案例表达式。当它找到一个计算结果为true的表达式时,$switch执行一个指定的表达式并退出控制流。 |  
日期表达式运算符
以下运算符返回日期对象或日期对象的组成部分:
| 名称 | 描述 | 
|---|---|
| $dateFromParts | 给出日期的组成部分,构造一个 BSON Date对象。 | 
| $dateFromString | 将 date/time 字符串转换为 date 对象。 | 
| $dateToParts | 返回包含 date 组成部分的文档。 | 
| $dateToString | 将 date 作为格式化的 string 返回。 | 
| $dayOfMonth | 将 date 的月中某天返回为 1 到 31 之间的数字。 | 
| $dayOfWeek | 将 date 的星期几返回为 1(星期日)和 7(星期六)之间的数字。 | 
| $dayOfYear | 将 date 的年中日期作为 1 到 366(闰年)之间的数字返回。 | 
| $hour | 将 date 的小时数作为 0 到 23 之间的数字返回。 | 
| $isoDayOfWeek | 返回 ISO 8601 格式的工作日编号,范围从1(星期一)到7(星期日)。 |  
| $isoWeek | 返回 ISO 8601 格式的周数,范围从1到53。 星期数从1开始,周(星期一到星期日)包含年份的第一个星期四。 |  
| $isoWeekYear | 以 ISO 8601 格式返回年份编号。年份从第 1 周的星期一(ISO 8601)开始,结束于上周的星期日(ISO 8601)。 | 
| $millisecond | 返回 date 的毫秒数,作为 0 到 999 之间的数字。 | 
| $minute | 将 date 的分钟作为 0 到 59 之间的数字返回。 | 
| $month | 将 date 的月份返回为 1(1 月)和 12(12 月)之间的数字。 | 
| $second | 返回 date 的秒数,作为 0 到 60 之间的数字(闰秒)。 | 
| $toDate | 将值转换为日期。 版本4.0中的新功能。 | 
| $week | 返回 date 的周数,作为 0(在一年的第一个星期日之前的部分周)和 53(闰年)之间的数字。 | 
| $year | 将 date 的年份作为数字返回(例:2014)。 | 
以下算术运算符可以使用 date 操作数:
| 名称 | 描述 | 
|---|---|
| $add | 添加 numbers 和 date 以返回新的 date。如果添加 numbers 和 date,则将 numbers 视为毫秒。接受任意数量的参数表达式,但最多只能有一个表达式解析为 date。 | 
| $subtract | 返回从第一个中减去第二个值的结果。如果这两个值是日期,则返回差异(以毫秒为单位)。如果这两个值是 date 和一个以毫秒为单位的数字,返回结果 date。接受两个参数表达式。如果这两个值是 date 和数字,请首先指定 date 参数,因为从数字中减去 date 没有意义。 | 
文字表达式运算符
| 名称 | 描述 | 
|---|---|
| $literal | 无需解析即可返回 value。用于聚合管道可以将其解释为表达式的值。例如,对以$开头的字符串使用]$literal表达式,以避免解析为字段路径。 | 
对象表达式运算符
| 名称 | 描述 | 
|---|---|
| $mergeObjects | 将多个文档合并为一个文档。 version 3.6 中的新内容。 | 
| $objectToArray | 将文档转换为表示 key-value 对的文档的 array。 version 3.6 中的新内容。 | 
集合表达式运算符
Set 表达式对数组执行 set 操作,将数组视为 sets。 Set 表达式忽略每个输入数组中的重复条目和元素的顺序。
如果 set 操作返回一个 set,则该操作会过滤掉结果中的重复项,以输出仅包含唯一条目的 array。输出 array 中元素的顺序未指定。
如果集合包含嵌套的 array 元素,则 set 表达式不会下降到嵌套的 array 中,而是在顶层level 处计算 array。
| 名称 | 描述 | 
|---|---|
| $allElementsTrue | 如果没有集合的元素计算为false,则返回true,否则返回false。接受单个参数表达式。 |  
| $anyElementTrue | 如果集合中的任何元素求值为true,则返回true;否则,返回false。接受单个参数表达式。 |  
| $setDifference | 返回一个集合,其中的元素出现在第一个集合中但不出现在第二个集合中; 即:相对于第一组执行第二组的相对补充。接受两个参数表达式。 | 
| $setEquals | 如果输入 sets 具有相同的不同元素,则返回true。接受两个或多个参数表达式。 |  
| $setIntersection | 返回一个包含所有输入 sets 中出现的元素的集合。接受任意数量的参数表达式。 | 
| $setIsSubset | 如果第一组的所有元素出现在第二组中,则返回true,包括第一组的等于第二组的时间; 即:不是严格的子集。接受两个参数表达式。 |  
| $setUnion | 返回一个包含任何输入 sets 中出现的元素的集合。 | 
字符串表达式运算符
字符串表达式(除外 $concat)仅对ASCII字符字符串具有明确定义的行为。
$concat 行为是明确定义的,与所使用的字符无关。
| 名称 | 描述 | 
|---|---|
| $concat | 连接任意数量的 strings。 | 
| $dateFromString | 将 date/time string 转换为 date object。 | 
| $dateToString | 将 date 作为格式化的 string 返回。 | 
| $indexOfBytes | 搜索 string 以查找子字符串的出现并返回第一次出现的 UTF-8 字节索引。如果未找到子字符串,则返回-1。 |  
| $indexOfCP | 搜索 string 以查找子字符串的出现并返回第一次出现的 UTF-8 code 点索引。如果找不到子字符串,则返回-1 |  
| $ltrim | 从字符串开头删除空格或指定的字符。 版本4.0中的新功能。 | 
| $regexFind | 将正则表达式(regex)应用于字符串,并返回第一个匹配的子字符串的信息。 4.2版中的新功能。 | 
| $regexFindAll | 将正则表达式(regex)应用于字符串,并返回所有匹配的子字符串的信息。 4.2版中的新功能。 | 
| $regexMatch | 将正则表达式(regex)应用于字符串,并返回一个布尔值,该布尔值指示是否找到匹配项。 4.2版中的新功能。 | 
| $rtrim | 从字符串末尾删除空格或指定的字符。 版本4.0中的新功能。 | 
| $split | 根据分隔符将 string 拆分为子字符串。返回子字符串的 array。如果在 string 中找不到分隔符,则返回包含原始 string 的 array。 | 
| $strLenBytes | 返回 string 中 UTF-8 编码字节的数量。 | 
| $strLenCP | 返回 string 中 UTF-8 code 点的数量。 | 
| $strcasecmp | 执行 case-insensitive string 比较并返回:如果两个 strings 相等则返回0,如果第一个 string 大于第二个,则返回1,如果第一个 string 小于第二个,则返回-1。 |  
| $substr | 已过时。使用$substrBytes或$substrCP。 | 
| $substrBytes | 返回 string 的子字符串。从 string 中指定的 UTF-8 字节索引(zero-based)处的字符开始,并继续指定的字节数。 | 
| $substrCP | 返回 string 的子字符串。从 string 中指定的 UTF-8 code point(CP)索引(zero-based)处的字符开始,并继续指定的 code 点数。 | 
| $toLower | 将 string 转换为小写。接受单个参数表达式。 | 
| $toString | 将值转换为字符串。 版本4.0中的新功能。 | 
| $trim | 从字符串的开头和结尾删除空格或指定的字符。 版本4.0中的新功能。 | 
| $toUpper | 将 string 转换为大写。接受单个参数表达式。 | 
文本表达式运算符
| 名称 | 描述 | 
|---|---|
| $meta | 访问文本搜索元数据。 | 
三角表达式运算符
三角表达式对数字执行三角运算。表示角度的值始终以弧度为单位输入或输出。使用 $degreesToRadians和$radiansToDegrees在度和弧度测量之间转换。
| 名称 | 描述 | 
|---|---|
| $sin | 返回以弧度为单位的值的正弦值。 | 
| $cos | 返回以弧度为单位的值的余弦值。 | 
| $tan | 返回以弧度为单位的值的切线。 | 
| $asin | 返回弧度值的反正弦(弧正弦)。 | 
| $acos | 返回弧度值的反余弦(弧余弦)。 | 
| $atan | 返回弧度值的反正切(弧切)。 | 
| $atan2 | 返回弧度表示的y / x的反正切(弧切线),其中y和x是分别传递给表达式的第一个和第二个值。 |  
| $asinh | 返回弧度值的反双曲正弦(双曲反正弦)。 | 
| $acosh | 返回弧度值的反双曲余弦(双曲反余弦)。 | 
| $atanh | 返回弧度值的反双曲正切(双曲反正切)。 | 
| $degreesToRadians | 将值从度转换为弧度。 | 
| $radiansToDegrees | 将值从弧度转换为度。 | 
类型表达式运算符
| 名称 | 描述 | 
|---|---|
| $convert | 将值转换为指定的类型。 版本4.0中的新功能。 | 
| $toBool | 将值转换为布尔值。 版本4.0中的新功能。 | 
| $toDate | 将值转换为日期。 版本4.0中的新功能。 | 
| $toDecimal | 将值转换为Decimal128。 版本4.0中的新功能。 | 
| $toDouble | 将值转换为双精度。 版本4.0中的新功能。 | 
| $toInt | 将值转换为整数。 版本4.0中的新功能。 | 
| $toLong | 将值转换为long。 版本4.0中的新功能。 | 
| $toObjectId | 将值转换为ObjectId。 版本4.0中的新功能。 | 
| $toString | 将值转换为字符串。 版本4.0中的新功能。 | 
| $type | 返回该字段的BSON数据类型。 | 
累加器($group)
累加器是可以在$group阶段使用的运算符,它们在文档通过管道时保持其状态(例如: 总计,最大值,最小值和相关数据)。
当在$group阶段用作累加器时,这些运算符将单个表达式作为输入,为每个输入文档计算一次表达式,并为共享相同 group key 的 group 文档保持其阶段。
| 名称 | 描述 | 
|---|---|
| $addToSet | 返回每个 group 的唯一表达式值的 array。 数组元素的顺序是未定义的。 | 
| $avg | 返回数值的平均值。忽略非数字值。 | 
| $first | 从每个 group 的第一个文档返回一个值。仅当文档按定义的顺序定义顺序。 | 
| $last | 从每个 group 的最后一个文档返回一个值。仅当文档按定义的顺序定义顺序。 | 
| $max | 返回每个 group 的最高表达式值。 | 
| $mergeObjects | 返回通过组合每个 group 的输入文档创建的文档。 | 
| $min | 返回每个 group 的最低表达式值。 | 
| $push | 返回每个 group 的表达式值的 array。 | 
| $stdDevPop | 返回输入值的总体标准偏差。 | 
| $stdDevSamp | 返回输入值的 sample 标准偏差。 | 
| $sum | 返回数值的总和。忽略非数字值。 | 
累加器(处于其他阶段)
一些可用作$group阶段累加器的运算符也可用于$project阶段,但不能用作累加器。在$project阶段使用时,这些 operator 不会维护它们的 state,并且可以将单个参数或多个 arguments 作为输入。
更改了 version 3.2.
以下累加器 operators 也可用于$project、$addFields和$set阶段。
| 名称 | 描述 | 
|---|---|
| $avg | 返回每个文档的指定表达式或表达式列表的平均值。忽略非数字值。 | 
| $max | 返回每个文档的指定表达式或表达式列表的最大值。 | 
| $min | 返回每个文档的指定表达式或表达式列表的最小值。 | 
| $stdDevPop | 返回输入值的总体标准偏差。 | 
| $stdDevSamp | 返回输入值的样本标准偏差。 | 
| $sum | 返回数值的总和。忽略非数字值。 | 
变量表达式运算符
| 名称 | 描述 | 
|---|---|
| $let | 定义在子表达式范围内使用的变量,并返回子表达式的结果。接受命名参数。 接受任意数量的参数表达式。 | 
表达式运算符的字母顺序列表
| 名称 | 描述 | 
|---|---|
| $abs | 返回数字的绝对值。 | 
| $acos | 返回弧度值的反余弦(弧余弦)。 | 
| $acosh | 返回弧度值的反双曲余弦(双曲反余弦)。 | 
| $add | 添加数字以返回总和,或者添加数字和日期以返回新日期。如果添加数字和日期,则将数字视为毫秒。接受任意数量的参数表达式,但最多只能一个表达式解析为日期。 | 
| $addToSet | 返回每个 group 的唯一表达式值的 array。 数组元素的顺序是未定义的。 仅适用于$group阶段 | 
| $allElementsTrue | 如果没有集合的元素计算为false,则返回true,否则返回false。接受单个参数表达式。 |  
| $and | 仅当其所有表达式求值为true时才返回true。接受任意数量的参数表达式。 |  
| $anyElementTrue | 如果集合中的任何元素求值为true,则返回true;否则,返回false。接受单个参数表达式。 |  
| $arrayElemAt | 返回指定的 array 索引处的元素。 | 
| $arrayToObject | 将键值对的 array 转换为文档。 | 
| $asin | 返回弧度值的反正弦(弧正弦)。 | 
| $asinh | 返回弧度值的反双曲正弦(双曲反正弦)。 | 
| $atan | 返回弧度值的反正切(弧切)。 | 
| $atan2 | 返回弧度表示的y / x的反正切(弧切线),其中y和x是分别传递给表达式的第一个和第二个值。 |  
| $atanh | 返回弧度值的反双曲正切(双曲反正切)。 | 
| $avg | 返回数值的平均值。忽略非数字值。 在 version 3.2 中更改:在$group和$project阶段均可用。 | 
| $ceil | 返回大于或等于指定数字的最小整数。 | 
| $cmp | 如果两个值相等则返回0,如果第一个 value 大于第二个值则返回1,如果第一个 value 小于第二个值,则返回-1。 |  
| $concat | 连接任意数量的字符串。 | 
| $concatArrays | 连接数组以返回连接的数组。 | 
| $cond | 一个三元运算符,它计算一个表达式,并根据结果返回另外两个表达式之一的值。接受有序列表中的三个表达式或三个命名参数。 | 
| $convert | 将值转换为指定的类型。 | 
| $cos | 返回以弧度为单位的值的余弦值。 | 
| $dateFromParts | 给出 date 的组成部分,构造一个 BSON Date对象。 | 
| $dateToParts | 返回包含 date 组成部分的文档。 | 
| $dateFromString | 返回 date/time 作为 date 对象。 | 
| $dateToString | 将 date 作为格式化的 string 返回。 | 
| $dayOfMonth | 将 date 的月中某天返回为 1 到 31 之间的数字。 | 
| $dayOfWeek | 将 date 的星期几返回为 1(星期日)和 7(星期六)之间的数字。 | 
| $dayOfYear | 将 date 的年中日期作为 1 到 366(闰年)之间的数字返回。 | 
| $degreesToRadians | 将值从度转换为弧度。 | 
| $divide | 返回将第一个数除以第二个数的结果。接受两个参数表达式。 | 
| $eq | 如果值相等,则返回true。 |  
| $exp | 将 e 提高到指定的指数。 | 
| $filter | 选择 array 的子集以返回 array 仅包含 match 过滤条件的元素。 | 
| $first | 从每个 group 的第一个文档返回一个 value。仅当文档位于已定义的 order 中时才定义 Order。 仅适用于$group阶段。 | 
| $floor | 返回小于或等于指定数字的最大 integer。 | 
| $gt | 如果第一个 value 大于第二个,则返回true。 |  
| $gte | 如果第一个 value 大于或等于第二个,则返回true。 |  
| $hour | 将 date 的小时数作为 0 到 23 之间的数字返回。 | 
| $ifNull | 如果第一个表达式导致 null 结果,则返回第一个表达式的 non-null 结果或第二个表达式的结果。空结果包含未定义值或缺少字段的实例。接受两个表达式作为参数。第二个表达式的结果可以为 null。 | 
| $in | 返回一个 boolean,指示指定的 value 是否在 array 中。 | 
| $indexOfArray | 搜索 array 以查找指定 value 的出现并返回第一次出现的 array 索引。如果未找到子字符串,则返回-1。 |  
| $indexOfBytes | 搜索 string 以查找子字符串的出现并返回第一次出现的 UTF-8 字节索引。如果未找到子字符串,则返回-1。 |  
| $indexOfCP | 搜索 string 以查找子字符串的出现并返回第一次出现的 UTF-8 code 点索引。如果未找到子字符串,则返回-1。 |  
| $isArray | 确定操作数是否为 array。返回 boolean。 | 
| $isoDayOfWeek | 返回 ISO 8601 格式的工作日编号,范围从1(星期一)到7(星期日)。 |  
| $isoWeek | 返回 ISO 8601 格式的周数,范围从1到53。 Week numbers 从1开始,周(星期一到星期日)包含年份的第一个星期四。 |  
| $isoWeekYear | 以 ISO 8601 格式返回年份编号。年份从第 1 周的星期一(ISO 8601)开始,结束于上周的星期日(ISO 8601)。 | 
| $last | 从每个 group 的最后一个文档返回一个 value。仅当文档位于已定义的 order 中时才定义 Order。 仅适用于$group阶段。 | 
| $let | 定义在子表达式范围内使用的变量,并返回子表达式的结果。接受命名参数。 接受任意数量的参数表达式。 | 
| $literal | 无需解析即可返回 value。用于聚合管道可以将其解释为表达式的值。例如,对以$开头的字符串使用$literal表达式,以避免解析为字段路径。 | 
| $ln | 计算数字的自然对数。 | 
| $log | 计算指定基数中的数字的对数。 | 
| $log10 | 计算数字的以10为底的对数。 | 
| $lt | 如果第一个 value 小于第二个,则返回true。 |  
| $lte | 如果第一个 value 小于或等于第二个值,则返回true。 |  
| $ltrim | 从字符串开头删除空格或指定的字符。 | 
| $map | 将子表达式应用于 array 的每个元素,并按顺序返回结果值的 array。接受命名参数。 | 
| $max | 返回每个 group 的最高表达式 value。 在 version 3.2 中更改:在$group和$project阶段均可用。 | 
| $mergeObjects | 将多个文档合并为一个文档。 | 
| $meta | 访问文本搜索元数据。 | 
| $min | 返回每个 group 的最低表达式 value。 在 version 3.2 中更改:在$group和$project阶段均可用。 | 
| $millisecond | 返回 date 的毫秒数,作为 0 到 999 之间的数字。 | 
| $minute | 将 date 的分钟作为 0 到 59 之间的数字返回。 | 
| $mod | 返回第一个数字的余数除以第二个数字。接受两个参数表达式。 | 
| $month | 将 date 的月份返回为 1(1 月)和 12(12 月)之间的数字。 | 
| $multiply | 乘以数字可返回乘积。接受任意数量的参数表达式。 | 
| $ne | 如果值不相等,则返回true。 |  
| $not | 返回与其参数表达式相反的布尔值。接受单个参数表达式。 | 
| $objectToArray | 将文档转换为表示键值对的文档的 array。 | 
| $or | 当任何表达式求值为true时返回true。接受任意数量的参数表达式。 |  
| $pow | 将数字提高到指定的指数。 | 
| $push | 返回每个 group 的表达式值的 array。 仅适用于$group阶段。 | 
| $range | 根据用户定义输入输出包含整数序列的 array。 | 
| $reduce | 将表达式应用于 array 中的每个元素,并将它们组合为单个 value。 | 
| $regexFind | 将正则表达式(regex)应用于字符串,并返回第一个匹配的子字符串的信息。 | 
| $regexFindAll | 将正则表达式(regex)应用于字符串,并返回所有匹配的子字符串的信息。 | 
| $regexMatch | 将正则表达式(regex)应用于字符串,并返回一个布尔值,该布尔值指示是否找到匹配项。 | 
| $reverseArray | 返回具有相反顺序元素的 array。 | 
| $round | 将数字四舍五入为整数或指定的小数位。 | 
| $rtrim | 从字符串末尾删除空格或指定的字符。 | 
| $second | 返回 date 的秒数,作为 0 到 60 之间的数字(闰秒)。 | 
| $setDifference | 返回一个集合,其中的元素出现在第一个集合中但不出现在第二个集合中; 即:相对于第一组执行第二组的相对补充)。接受两个参数表达式。 | 
| $setEquals | 如果输入集合具有相同的不同元素,则返回true。接受两个或多个参数表达式。 |  
| $setIntersection | 返回一个包含所有输入集合中出现的元素的集合。接受任意数量的参数表达式。 | 
| $setIsSubset | 如果第一组的所有元素出现在第二组中,则返回true,包括第一组的等于第二组的时间; 即:不是严格的子集。接受两个参数表达式。 |  
| $setUnion | 返回一个包含任何输入集合中出现的元素的集合。 | 
| $size | 返回 array 中的元素数。接受单个表达式作为参数。 | 
| $sin | 返回以弧度为单位的值的正弦值。 | 
| $slice | 返回 array 的子集。 | 
| $split | 根据分隔符将 string 拆分为子字符串。返回子字符串的 array。如果在 string 中找不到分隔符,则返回包含原始 string 的 array。 | 
| $sqrt | 计算平方根。 | 
| $stdDevPop | 返回输入值的总体标准偏差。 在 version 3.2 中更改:在$group和$project阶段均可用。 | 
| $stdDevSamp | 返回输入值的样本标准偏差。 在 version 3.2 中更改:在$group和$project阶段均可用。 | 
| $strcasecmp | 执行不区分大小写的字符串比较并返回:如果两个字符串相等则返回0,如果第一个字符串大于第二个,则返回1,如果第一个字符串小于第二个,则返回-1。 |  
| $strLenBytes | 返回 string 中 UTF-8 编码字节的数量。 | 
| $strLenCP | 返回 string 中 UTF-8 code 点的数量。 | 
| $substr | 已过时。使用$substrBytes或$substrCP。 | 
| $substrBytes | 返回 string 的子字符串。从 string 中指定的 UTF-8 字节索引(从零开始)处的字符开始,并继续指定的字节数。 | 
| $substrCP | 返回 string 的子字符串。从 string 中指定的 UTF-8 code point(CP)索引(从零开始)处的字符开始,并继续指定的 code 点数 | 
| $subtract | 返回从第一个中减去第二个 value 的结果。如果这两个值是数字,返回差值。如果这两个值是日期,则返回差值(以毫秒为单位)。如果这两个值是 date 和一个以毫秒为单位的数字,则返回结果 date。接受两个参数表达式。如果这两个值是 date 和数字,请首先指定 date 参数,因为从数字中减去 date 没有意义。 | 
| $sum | 返回数值的总和。忽略非数字值。 在 version 3.2 中更改:在$group和$project阶段均可用。 | 
| $switch | 计算一系列案例表达。当它找到一个计算结果为true的表达式时,$switch执行一个指定的表达式并退出控制流。 |  
| $tan | 返回以弧度为单位的值的切线。 | 
| $toBool | 将值转换为布尔值。 | 
| $toDate | 将值转换为日期。 | 
| $toDecimal | 将值转换为Decimal128。 | 
| $toDouble | 将值转换为双精度。 | 
| $toInt | 将值转换为整数。 | 
| $toLong | 将值转换为long。 | 
| $toObjectId | 将值转换为ObjectId。 | 
| $toString | 将值转换为字符串。 | 
| $toLower | 将 string 转换为小写。接受单个参数表达式。 | 
| $toUpper | 将 string 转换为大写。接受单个参数表达式。 | 
| $trim | 从字符串的开头和结尾删除空格或指定的字符。 | 
| $trunc | 截断其整数的数字。 | 
| $type | 返回该字段的 BSON 数据类型。 | 
| $week | 返回 date 的周数,作为 0(在一年的第一个星期日之前的部分周)和 53(闰年)之间的数字。 | 
| $year | 将 date 的年份作为数字返回(例:2014)。 | 
| $zip | 将两个数组合并在一起。 | 
对于管道阶段,请参见聚合管道阶段。
译者:李冠飞
校对:
Copyright © 上海锦木信息技术有限公司 all right reserved,powered by Gitbook文件修订时间: 2020-12-18 11:34:57
