Vadorequest
Vadorequest

Reputation: 18009

Confused by MongoDb documentation Collection.remove

I'm just learning how use mongoDb and I get confused by the documentation about the Collection.remove() method.

In first place, I tried to follow this doc: http://docs.mongodb.org/manual/reference/method/db.collection.remove/

But I got the message Error: Cannot use a writeConcern without a provided callback, so I searchd why and I found this documentation then: http://mongodb.github.io/node-mongodb-native/api-generated/collection.html

In the first one there are two args, in the second there are three.

Then I did a console.log((mongodb.Collection(db, 'user').remove).toString());

And I got function remove(selector, options, callback)...

So now I just don't understand what's going on here, Is there different kind of Collection class? I whish to understand which documentation I should follow.

Upvotes: 0

Views: 201

Answers (1)

Oleg
Oleg

Reputation: 23297

It seems like you just have to provide a callback-function:

Collection.remove(function(err, removedCount) {
    //your next actions
});

From documentation:

[callback] (function) – must be provided if you performing a remove with a writeconcern

Upvotes: 1

Related Questions