Delete Document

MongoDB collection of documentation, if needed, can be permanently deleted by the delete command.

Syntax: db.collection.remove

db.getCollection("test").remove(
    {
        price: {$gt: 100}
    },
    writeconcern: {w: "majority", wtimeout: 3000}
)

(Delete Price Boy all documentation 3, when the time is more than five seconds, or the majority of the replica set has been completed this command is executed, interrupts the execution of the command, return to the operating results of the command)

db.getCollection("test").remove(
    {
        price: {$gt: 100}
    },
    justOne: true
)

(Deletion price is greater than the first documented 3)


To remove the entire documentation with db.collection.drop () method more efficient, it will delete the entire collection together and indexes.

Guess you like

Origin blog.51cto.com/5660061/2422628