Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'deleteMany' of object xxx is not a function in MongoDb

Tags:

mongodb

I am trying to use deletemany in mongodb version 2.6.10? However it gives me error.

Here is my query;

> db.person.deleteMany(  {gallery : {$ne:"test"} } );
2017-08-08T13:50:42.580+0300 TypeError: Property 'deleteMany' of object testdb.person is not a function

How I can delete content with where clause?

like image 605
goGud Avatar asked Aug 08 '17 11:08

goGud


2 Answers

This works for me

db.person.remove(  {gallery : {$ne:"test"} } );
like image 110
Andrews Agyemang Opoku Avatar answered Dec 05 '22 14:12

Andrews Agyemang Opoku


To delete some records we can use: db.person.remove( {gallery : {$ne:"test"} } );

To delete all records from a collection: db.person.remove({});

like image 44
anvesh Avatar answered Dec 05 '22 16:12

anvesh