909422229_MongoDB基本操作
2017-05-24 15:13
232 查看
//查看全部
db.test.find()
//查看数据库状态
db.status
// 帮助
db.help()
//插入数据
db.test.insert(
{name:'sleep',price:2222}
)
//插入带有数组的数据
db.test.insert([{name:'增删改差测试',price:1000,style:{size:'10px',width:'20px'}}])
//查询单挑数据
db.test.findOne();
//多个数据查询
//查询大于1000元的数据
db.test.find(
{price:{'$gt': 1000}})
//查询小于1000元的数据
db.test.find({price:{'$lt':1000}})
//多条件查询数据
db.test.find({'name':'测试'},{price:500})
//查询数据大于等500小雨等于2222的升级快
//db.test.find({price:{'$gte': 500},price:{'$lte':2222}})
//查询满足一条数据即可展示的数据
db.test.find({'$or': [{name:'abc'},{price:5000}]})
//查询带有数组的数据
db.test.find({'对象.属性':'属性参数'})
db.test.find({'style.size':'10px'})
//查询指定显示字段的数据
db.test.find({'查询条件':'条件'},{'指定显示的字段[可多个]':'1/0'})
db.test.find({price:2000},{name:1,_id:0,price:1})
//修改数据
//根据条件修改数据
db.test.update({name:'测试'},{$set:{name:'修改测试'}})
//删除数据
db.test.remove({name:null})
db.test.remove({'$or': [{id:500},{price:null}]})
db.test.remove({abc_id:1234})
db.test.find()
//查看数据库状态
db.status
// 帮助
db.help()
//插入数据
db.test.insert(
{name:'sleep',price:2222}
)
//插入带有数组的数据
db.test.insert([{name:'增删改差测试',price:1000,style:{size:'10px',width:'20px'}}])
//查询单挑数据
db.test.findOne();
//多个数据查询
//查询大于1000元的数据
db.test.find(
{price:{'$gt': 1000}})
//查询小于1000元的数据
db.test.find({price:{'$lt':1000}})
//多条件查询数据
db.test.find({'name':'测试'},{price:500})
//查询数据大于等500小雨等于2222的升级快
//db.test.find({price:{'$gte': 500},price:{'$lte':2222}})
//查询满足一条数据即可展示的数据
db.test.find({'$or': [{name:'abc'},{price:5000}]})
//查询带有数组的数据
db.test.find({'对象.属性':'属性参数'})
db.test.find({'style.size':'10px'})
//查询指定显示字段的数据
db.test.find({'查询条件':'条件'},{'指定显示的字段[可多个]':'1/0'})
db.test.find({price:2000},{name:1,_id:0,price:1})
//修改数据
//根据条件修改数据
db.test.update({name:'测试'},{$set:{name:'修改测试'}})
//删除数据
db.test.remove({name:null})
db.test.remove({'$or': [{id:500},{price:null}]})
db.test.remove({abc_id:1234})
相关文章推荐
- MongoDB 基本操作语法
- 用php实现mongoDB的基本操作
- MongoDB最基本的操作
- MongoDB 一些基本操作<二>
- Nosql :MongoDB一些基本操作<二>
- [Database] MongoDB (1) 基本连接、操作、查询
- 【NOSQL】非关系型数据库MongoDB ( 通过samus驱动实现基本数据操作 )
- [ mongoDB ] - mongoDB的基本操作
- MongoCola使用教程 1 - MongoDB的基本操作和聚合功能
- 学习MongoDB--(2-2):MongoDB入门(Shell基本操作)
- MongoDB聚集索引基本操作
- MongoDB 通过samus驱动实现基本数据操作
- mongodb文档及基本操作
- mongodb基本操作
- 用php实现mongoDB的基本操作
- MongoDB数据表基本操作
- 用php实现mongoDB的基本操作
- MongoDB 基本操作
- Nosql :MongoDB一些基本操作<一>
- MongoDb 关于数据库的基本操作