zl程序教程

您现在的位置是:首页 >  其他

当前栏目

MongoDB mongosh terminal 常用命令 Mac

2023-04-18 16:14:08 时间

use help to get access to the frequent commands

help

show all databases

show dbs

use a certain database, use "newdb"

use newdb

Delete

Delete All Documents

To remove all documents from a collection, pass an empty filter document {} to either the db.collection.deleteMany() or the db.collection.remove() method.

https://docs.mongodb.com/v3.2/tutorial/remove-documents/#delete-all-documents

DeprecationWarning: Collection.remove() is deprecated. Use deleteOne, deleteMany, findOneAndDelete, or bulkWrite.

eg. Delete all documents in "newcollection"

db.newcollection.deleteMany({})

用 Compass 导入 json 文件时,文件内容的最外层要有 []