zoukankan      html  css  js  c++  java
  • mongodb使用小点

    查询某个字段存在的语句

    db.getCollection('tableName').find({"RouteInfo":{"$exists":true}})

    查询某个字段不存在的语句 

    db.getCollection('tableName').find({"RouteInfo":{"$exists":false}})

    // 查某个数组属性的数组大小为1的
    db.collection.find( { field: { $size: 1 } } );

    // 查数组属性results匹配的
    db.scores.find({ results: { $elemMatch: { $gte: 80, $lt: 85 } } })

    // 分组count

    db.getCollection('moments').aggregate( [{ "$group" : { "_id" : "$school.schoolId", "Count" : { "$sum" : 1 } } }])

    // 使用其他collection的值更新关联的collection的字段值

    db.getCollection('notices').find({}).forEach(function(notice) {
      db.getCollection('noticereceivedetails').update(
        { "_notice": notice._id },
        { $set: { 'institutionId': NumberInt(notice.institutionId) }},
        { multi: true }
      )
    })

  • 相关阅读:
    python3第六天
    python3第五天
    python3第四天
    python3 第三天
    python3第二天
    python3(2)
    python3(1)
    网络通信 & 初识socket
    python中包的语法
    模块语法
  • 原文地址:https://www.cnblogs.com/petunsecn/p/12289990.html
Copyright © 2011-2022 走看看