Mongo 查询(可视化工具)

distinct

  MongoDB 的 distinct 命令是获取特定字段中不同值列表的最简单工具。

  该命令适用于普通字段、数组字段以及数组内嵌文档(集合对象)。

  db.getCollection('customer').distinct("customer_type")
  // chances字段的值是个集合,获取集合内每个对象的opportunitytype字段的值域
  db.getCollection('customer').distinct("chances.opportunitytype")

  统计某几个人的共同好友:

  db.person.distinct("myFriends", {"manName" : {"$in" : ["ZhenQin""YangYan"]}})

  使用 runCommand 命令来写:

    下面的示例返回 inventory 集合的 dept 字段的值域:

   db.runCommand ( { distinct: "inventory", key: "dept" } )

    下面的示例返回 inventory 集合中 dept 取值为 "A" 的结果集中的 “item.sku” 字段的值域:

   db.runCommand ( { distinct: "inventory", key: "item.sku", query: { dept: "A"} } )

 

转载于:https://www.cnblogs.com/zhangchaoran/p/9969610.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值