Mongodb 聚合命令

xiaoxiao2021-02-28  23

aggregation 命令 除了已经介绍过的 aggregate mapReduce 还有 count 、 distinct、group;在大多数情况下这三个已经被聚合框架取代了,

操作意义实例备注count返回文档数量db.c.count({})runCommand({ count: collection or view,query: document,limit: integer,skip: integer,hint: hint,readConcern: document})条件查询不如 find 快distinct返回指定键的不同值db.runCommand ( { distinct: “myCollection”, key: “myKey” } )返回格式{”values” : [ “1”, “a”, “2b” ], “ok” : 1}group分组db.c.group()Mongodb 3.4后建议使用db.collection.aggregate() 或者 db.collection.mapReduce()

count文档 distinct文档 group 文档

转载请注明原文地址: https://www.6miu.com/read-2650284.html

最新回复(0)