zoukankan      html  css  js  c++  java
  • mongo常用查询

    复杂查询
    and:
    or:
    lte,gte,=:

    and+lt:  , 逗号表示and, $lt小于写在值当中
    查询实例
    找到含有指定数据文档
    查找条件spcode有1个字符长度的文档
    db.spgoods.find({"spcode":{$regex: "^.{1,1}$"}})
    查找条件spcode有1-6个字符长度的文档
    db.spgoods.find({"spcode":{$regex: "^.{1,1}$"}})

    更新一批数据
    db.spgoods.update({"spcode":{$regex: "^.{1,6}$"}},{$set:{"depart":131,"comp":4,"operator":133,"upload":true}},false,true)

    只更新第一条记录:

    db.col.update( { "count" : { $gt : 1 } } , { $set : { "test2" : "OK"} } );

    全部更新:

    db.col.update( { "count" : { $gt : 3 } } , { $set : { "test2" : "OK"} },false,true );

    只添加第一条:

    db.col.update( { "count" : { $gt : 4 } } , { $set : { "test5" : "OK"} },true,false );

    全部添加加进去:

    db.col.update( { "count" : { $gt : 5 } } , { $set : { "test5" : "OK"} },true,true );

    全部更新:

    db.col.update( { "count" : { $gt : 15 } } , { $inc : { "count" : 1} },false,true );

    只更新第一条记录:

    db.col.update( { "count" : { $gt : 10 } } , { $inc : { "count" : 1} },false,false );



































  • 相关阅读:
    Linux使用手册
    Oracle&SQL使用记录
    docker的使用
    springboot与mybatis
    JavaScript与TypeScript总结
    React总结
    React与jsplumb
    DB2入门
    吾尝终日而思矣——2019.02.17
    吾尝终日而思矣——2019.02.12
  • 原文地址:https://www.cnblogs.com/wuqingzangyue/p/5770015.html
Copyright © 2011-2022 走看看