mongo

作者: sundern | 来源:发表于2019-04-17 23:28 被阅读0次

    1.mongo升级到3.5版本以上时:

    gatherTaskDao.getPropertyMaxValue中的聚合查询有bug,需要强制使用cursor指定分次查询的大小

    2.按主键查询数据:

    "_id":Object("123456")

    3.保存HTML的值到mongodb:

    先利用工具(notepad++)替换字符,\r\n 替换为空    " 替换为\"

    4.用正则式匹配字段以某字符开头并且以某字符结尾:reportCode:{$regex:/^T.*2019$/}

    正则匹配不包含某字符的记录^(?!a):summaryFormCode:{$regex:/^TX(?!3)/}(以TX开头但是第三个字符不为3)

    5.聚合查询的格式:db.news.aggregate([{$group:{_id: null, sumCount:{$sum:"$level"}}}])

    6.查询某个属性不为空:"headItem":{"$ne":null}  为空 “name”:null

    7.批量更新:db.getCollection('stats_agency_area').updateMany({

      "_class": "com.gwssi.stats.tjstandard.entity.AgencyArea"

    },

    {

      $set: {

        "_class": "com.gwssi.stats.agencyarea.entity.AgencyArea"

      }

    })

    8.聚合查询:

    9.排序,主键需要用_id

    10.String类型变int类型比较大小(最终也没能解决,写测试类)

    相关文章

      网友评论

          本文标题:mongo

          本文链接:https://www.haomeiwen.com/subject/mspnnftx.html