MongoDB shell 命令
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MongoDB shell 命令,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2527字,纯文字阅读大概需要4分钟。
内容图文
![MongoDB shell 命令](/upload/InfoBanner/zyjiaocheng/514/2ced5303f32b4577b318ea476f883472.jpg)
更新列名 db.Youzy_Stores.update({}, {$rename : {"StoreId" : "MetaId"}}, false, true) 查询长度 db.getCollection("Youzy_Stores_Navigations").find({$where:‘this.StoreId.length>2‘},{Name:0}) 查询总条数 db.getCollection("Youzy_Stores_BusinessLogs").find({}).count() 区间查询 db.getCollection("Youzy_Cards").find({‘StoreId‘:1139,‘CardNo‘:{‘$gte‘:‘90225001‘,‘$lte‘:‘90295000‘}}) 多个区间查询 db.getCollection("Youzy_Cards").find({ $or : [{ $and : [{"CardNo" : { $gte : "10000001" }}, {"CardNo" : { $lte : "10000003" }}] }, { $and : [{"CardNo" : { $gte : "10000006" }}, {"CardNo" : { $lte : "10000008" }}] }] }).limit(1000).skip(0) 排序 1 升序 -1降序 db.getCollection("Youzy_Stores_BusinessLogs").find().sort({"CreationTime":1}) db.Youzy_Stores_Experts.find({‘PicId‘ : { $type : 16 }}).forEach(function(x) {x.PicId = String(x.PicId);db.Youzy_Stores_Experts.save(x); }) 添加一个字段. table 代表表名 , 添加字段 content,字符串类型。 db.table.update({}, {$set: {content:""}}, {multi: true}) 删除一个字段 db.table.update({},{$unset:{content:""}},false, true) 清空数据 db.table.remove({}) 查询指定列 db.news.find( {}, { id: 1, title: 1 } ) 修改列表 db.getCollection(‘Youzy_Orders_Scores‘).update({},{$rename:{"OId":‘MetaId‘}},false,true) 添加索引 db.test.createIndex({"username":1}) db.Youzy_Users_MobileAuthCodes.createIndex({"Code":1,"Mobile":1,"ExpiresTime":1},{"name":"MobileAuthCodes_Validate"}) //group db.getCollection("Youzy_Users_GaoKaoScores").aggregate([{$match:{"IsDeleted":false}},{$group : {_id : "$UserId", count : {$sum : 1}}},{$sort:{"count":-1}}]) --条件修改 //update db.getCollection(‘Youzy_Stores_Navigations‘).update( // query { "MenuKey" : 28 }, // update { $set:{"Url":"/tzy/choosebatch?type=3"} }, false, true ); 按照时间年月分组 db.Youzy_Users.aggregate([ {$match: { CreateDate: { $gte: new Date(‘2018-01-01‘), $lte: new Date(‘2019-07-31‘) } }} , {$group:{_id:{CreateDate:{year: { $year: "$CreateDate"},month: { $month: "$CreateDate" }}}, count: { $sum: 1 }}} ]) //分组 db.Youzy_Users.aggregate([ {$match: { CreateDate: { $gte: new Date(‘2017-01-01‘), $lte: new Date(‘2019-07-31‘) }}} , { "$group": { _id: { month: { $dateToString: { format: "%Y-%m", date: "$CreateDate" } } }, count: { $sum: 1 } } }, { "$project": { "年月": "$_id.month", "总数": "$count", } } ])
MongoDB shell 命令
标签:nbsp 区间查询 _id and rest ssl pre auth bsp
本文系统来源:https://www.cnblogs.com/panjuan/p/11697905.html
内容总结
以上是互联网集市为您收集整理的MongoDB shell 命令全部内容,希望文章能够帮你解决MongoDB shell 命令所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。