zoukankan      html  css  js  c++  java
  • 经常使用的mongodb命令

     

    以下演示collection是集合名

    以key为基准去重查看
    db.collection.distinct("keyname")

    查询命令

    等于
    db.collection.find({"name": "jack"})

    小于
    查询小于10的数据
    db.collection.find({"count":{$lt: 10}})

    小于或等于
    查询大于10的数据
    db.collection.find({"count":{$lte:10}})

    大于
    查询大于10的数据
    db.collection.find({"count": {$gt: 10}})

    大于或等于
    查询大于等于10的数据
    db.collection.find({"count": {$gte:10}})

    不等于
    查询不等于10的数据
    db.collection.find({"count": {$ne: 10}})

    美化输出
    pretty()
    db.collection.find({"name": "jack"}).pretty()

    and 条件
    mongodb的find()方法可以传入多个键,每个键(key)以逗号隔开
    db.collection.find({"name":"jack", "age": 18})

    or 条件
    mongodb or 条件语句使用了关键字$or
    db.collection.find({$or: [{"name": "jack", {"name": "peter"}}]})

  • 相关阅读:
    jQuery对表单的操作
    js-工厂模式
    js中call、apply、bind的区别
    js实现重载和重写
    js封装/继承/多态
    变量的解构赋值
    var & let & const 的区别
    jQuery之animate中的queue
    jQuery之动画
    .trigger
  • 原文地址:https://www.cnblogs.com/onesea/p/13405184.html
Copyright © 2011-2022 走看看