码迷,mamicode.com
首页 > 数据库 > 详细

MongoDB入门三

时间:2017-09-23 20:12:43      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:操作   time   position   weight   mes   分享   create   技术   nbsp   

MongoDB字段问题  增删查改操作


删除一列操作
db.RiderReaTimePositon.update({},{$unset:{‘CreateTime‘:‘‘}},false,true)
db.RiderReaTimePositon.update({},{$unset:{‘删除字段‘:‘‘}},false,true)
新增一列操作
db.RiderReaTimePositon.update({},{$set:{‘demo‘:‘‘}},false,true)
db.RiderReaTimePositon.update({},{$set:{‘新增字段‘:‘‘}},false,true)
MongoDB解决方案:http://www.cnblogs.com/mengfanrong/p/5185908.html
http://www.lai18.com/cate/99.html

 技术分享

//查询数据
db.testcol.find()

//插入数据
db.RiderPosition.insert({‘name‘:‘Jemm‘,‘age‘:‘26‘,‘weight‘:‘140‘,‘CreateTime‘:‘2017-08-02‘})

db.RiderPosition.insert({‘name‘:‘Jim‘,‘age‘:‘28‘,‘weight‘:‘156‘,‘CreateTime‘:‘2017-08-02 15:25:20‘})

db.RiderPosition.find()

//根据时间查询
db.RiderPosition.find().sort({‘CreateTime‘:-1})

 

MongoDB定时任务
db.RiderPosition.find()

db.log_event.insert({‘createAt‘:new Date(),‘logEvent‘:2,‘logMessage‘:‘success‘})

db.log_event.find()

db.log_event.createIndex({‘expireAt‘:1},{expireAfterSeconds:0})

db.log_event.insert({‘expireAt‘:new Date(‘August 2,2017 19:55:00‘),‘logEvent‘:2,‘logMessage‘:‘success‘})

MongoDB入门三

标签:操作   time   position   weight   mes   分享   create   技术   nbsp   

原文地址:http://www.cnblogs.com/badboys/p/7582015.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!