mongo常用语句整理

2020-07-31 15:40:24 浏览数 (1)

查询

数据结构为

代码语言:javascript复制
{
  "_id" : ObjectId("5b8509309126260016eb7276"),
  "departmentName" : "新闻中心",
  "cDetail" : {
    "contentHtml" : "<p>质保期对身体有害吗</p>",
    "content" : "质保期对身体有害吗n"
  },
  "src" : "线索",
  "utime" : "2018-08-28 16:38:41",
  "companyName" : "测试测试测试",
  "departmentId" : "5a330972970711e88dfbfa163e4f9930",
  "companyGroup" : "47942F934BE444539B7053EFE85E83F1",
  "cuserName" : "云南台管理员",
  "uuserName" : "云南台管理员",
  "statusDetail" : "处理成功",
  "appCode" : "QMTNRK_YUNSHI",
  "title" : "线索来源",
  "templateId" : "5b642d469c966153eeaee8ac",
  "extended" : {
    "cType" : "cTypeClue",
    "origin" : "指派",
    "belongerName" : "马疆南",
    "cStatus" : "审核通过并生成文稿",
    "belonger" : "2543EA83412D137AE48B4E",
    "examineId" : "FEB45D7B4E17E413BA38C49",
    "examineName" : "云南台管理员",
    "examineTime" : "2018-08-28 16:39:39"
  },
  "companyId" : "974837F6BEDD4973",
  "utimeStamp" : NumberLong("1535445521964"),
  "ctime" : "2018-08-28 16:34:56",
  "mIds" : [],
  "cuserId" : "B951C4519FEB45D7B4E17E413BA38C49",
  "isDel" : 0,
  "ctimeStamp" : NumberLong("1535445296825"),
  "uuserId" : "B951C4519FEB45D7B4E17E413BA38C49",
  "status" : "SUCCESS",
  "pushType" : "1"
}

查询title字段为"爱心守望 众志成城"的数据

代码语言:javascript复制
db.catalogue.find({'title': "爱心守望 众志成城"}).pretty();

模糊查询title字段为 “爱心守望 众志成城"的数据

代码语言:javascript复制
db.catalogue.find({'title': {"$regex": "爱心守望 众志成城"}}).pretty();

查询id为“5e39674d9c891f3e65928743”的数据

代码语言:javascript复制
db.catalogue.find( { "_id" : ObjectId("5e39674d9c891f3e65928743") } ).pretty();

0 人点赞