MongoDB学习六--MongoDB删除数据文档
2015-08-22 23:09
555 查看
In MongoDB, the db.collection.remove() method
removes documents from a collection. You can remove all documents from a collection, remove all documents that match a condition, or limit the operation to remove just a single document.
To
remove all documents from a collection, pass an empty query document {} to
the remove() method.
The remove() method
does not remove the indexes.
To remove all documents from a collection, it may be more efficient to use the drop() method
to drop the entire collection, including the indexes, and then recreate the collection and rebuild the indexes.
To
remove the documents that match a deletion criteria, call the remove() method
with the <query>parameter.
For large deletion operations, it may be more efficient to copy the documents that you want to keep to a new collection and
then use drop() on
the original collection.
To
remove a single document, call the remove() method
with the justOne parameter
set to true or 1.
To delete a single document sorted by some specified order, use the findAndModify() method.
removes documents from a collection. You can remove all documents from a collection, remove all documents that match a condition, or limit the operation to remove just a single document.
To
remove all documents from a collection, pass an empty query document {} to
the remove() method.
The remove() method
does not remove the indexes.
db.admin.remove({})
To remove all documents from a collection, it may be more efficient to use the drop() method
to drop the entire collection, including the indexes, and then recreate the collection and rebuild the indexes.
To
remove the documents that match a deletion criteria, call the remove() method
with the <query>parameter.
db.admin.remove( { type : "food" } )
For large deletion operations, it may be more efficient to copy the documents that you want to keep to a new collection and
then use drop() on
the original collection.
To
remove a single document, call the remove() method
with the justOne parameter
set to true or 1.
db.admin.remove( { type : "food" }, 1 )
To delete a single document sorted by some specified order, use the findAndModify() method.
相关文章推荐
- MongoDB
- Mongodb集群之副本集
- MongoDB 清除重复数据
- MongoDB查询简单语法
- MongoDB学习五--MongoDB修改数据文档
- nodejs+express+mongodb安装
- 用 mongodb + elasticsearch 实现中文检索
- mongoDB中的ID的生成原则
- MongoDB入门
- Mongodb语法总结
- PHP查询MongoDB慢的问题
- Mongodb常用命令
- [MongoDB] - mongod.exe参数详解
- mongodb 批量更新,删除
- [MongoDB] - Window7下安装及BSON基本介绍
- MongoDB 数据库下载和安装
- mongodb停止数据库
- MongoDB简介(一)
- mongodb文档概念
- mongodb删除集合