Truncate a collection

后端 未结 6 1585
無奈伤痛
無奈伤痛 2020-12-12 23:37

How do I truncate a collection in MongoDB or is there such a thing?

Right now I have to delete 6 large collections all at once and I\'m stopping the server, deleting

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 00:06

    The db.drop() method obtains a write lock on the affected database and will block other operations until it has completed.

    I think using the db.remove({}) method is better than db.drop().

提交回复
热议问题