MongoDB数据删除
时间:2018-10-24 17:02 来源:51cto.com 作者:51cto
1.查看集合
show collections
2.向集合中添加数据
db.runoob.insertOne(
{
'title':'remove method',
'url':'http://blog.51cto.com/suyanzhu',
'description':'this is my blog'
}
)
db.runoob.insertMany([
{
'title':'data1',
'url':'http://blog.51cto.com/suyanzhu',
'description':'this is data1'
},
{
'title':'data2',
'url':'http://blog.51cto.com/suyanzhu',
'description':'this is data2'
}
])
3.查看数据
db.runoob.find().pretty()
4.删除单个数据
db.runoob.deleteOne({'title':'remove method'})
5.查看数据
db.runoob.find().pretty()
(责任编辑:IT)
1.查看集合 show collections
2.向集合中添加数据 db.runoob.insertOne( { 'title':'remove method', 'url':'http://blog.51cto.com/suyanzhu', 'description':'this is my blog' } ) db.runoob.insertMany([ { 'title':'data1', 'url':'http://blog.51cto.com/suyanzhu', 'description':'this is data1' }, { 'title':'data2', 'url':'http://blog.51cto.com/suyanzhu', 'description':'this is data2' } ])
3.查看数据 db.runoob.find().pretty()
4.删除单个数据 db.runoob.deleteOne({'title':'remove method'})
5.查看数据 db.runoob.find().pretty() (责任编辑:IT) |