Deepak
Deepak

Reputation: 1584

How to remove given list of documents from collection mongodb

how to Remove given list of documents from mongodb collection? eg:

i want to remove list of students which name containing empty value like.

var list=db.Student.find({'Name': {$eq: ''}})

db.Student.update($pull:{list})

but its is not working. is there any other best solution for this?

Upvotes: 0

Views: 110

Answers (2)

ma08
ma08

Reputation: 3734

db.Student.remove({'Name':''})

Check the docs

Upvotes: 1

Manorama
Manorama

Reputation: 69

You can remove the documents with the given condition by passing a query document. Try this;

db.Student.remove( { Name : "" } )

You can refer this link for further clarifications. http://docs.mongodb.org/manual/tutorial/remove-documents/

Upvotes: 1

Related Questions