删除记录

mongo shell

删除多个

全部删除:

db.collectionName.deleteMany({})

删除特定条件的数据:

db.colelctionName.deleteMany({ fieldName : fieldValue })

举例:

db.inventory.deleteMany({ status : "A" })
db.gameShortLink.deleteMany({"input.generateDate":"20210816"})

mongo_shell_delete_many

删除单个

db.colelctionName.deleteOne({ fieldName : fieldValue })

举例:

db.inventory.deleteOne( { status: "D" } )

官网文档:

Delete Documents — MongoDB Manual

results matching ""

    No results matching ""