mafintosh/mongojs — pull request #114 by kapetan (2013-12-25 20:35:31+00:00)
Title: Normalize callback arguments. Same as shell.

Possible solution for issue [#22- .save() doesn't work](https://github.com/mafintosh/mongojs/issues/22), regarding inconsistent callback arguments.

Current callback arguments:

```javascript
db.users.insert(document, callback);	// => callback(err, [document])
db.users.save(document, callback);	// => callback(err, document)
db.users.update({ ... }, { ... }, callback); // => callback(err, 1, lastErrorObject)
db.users.remove({ ... }, callback); // => callback(err, 1)
db.users.findAndModify({ query: { ... }, update: { ... }}, callback); // => callback(err, document, { lastErrorObject: { ... }, value: document })
```

Where the `document` argument passed to the `insert` and `save` callbacks, is the same `document` used to call the functions with (`_id` added if not already present).

This commit strips all callback arguments (expect for `findAndModify`). This seems to be the way the mongo shell does it.

A solution for the `lastErrorObject` getting lost, could be to add it to the database instance, so you could do:

```javascript
db.users.findAndModify(..., function(err, document) {
console.log(db._lastErrorObject);
})
```