Skip to content

Commit

Permalink
{'forceServerObjectId':true} option added to db to force server to as…
Browse files Browse the repository at this point in the history
…sign objectid's instead of the client
  • Loading branch information
christkv committed Jun 1, 2011
1 parent 74d4b52 commit 0f50277
Show file tree
Hide file tree
Showing 3 changed files with 456 additions and 408 deletions.
2 changes: 1 addition & 1 deletion lib/mongodb/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Collection.prototype.insertAll = function insertAll (docs, options, callback) {
var doc = docs[index];

// Add id to each document if it's not already defined
if (!doc['_id']) {
if (!doc['_id'] && this.db.forceServerObjectId != true) {
doc['_id'] = this.pkFactory.createPk();
}

Expand Down
3 changes: 3 additions & 0 deletions lib/mongodb/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ var Db = exports.Db = function(databaseName, serverConfig, options) {
// If we tried to instantiate the native driver
throw "Native bson parser not compiled, please compile or avoid using native_parser=true";
}
debug(inspect(options))

// this.connections = [];
// State of the db connection
this.state = 'notConnected';
this.pkFactory = this.options.pk == null ? this.bson_serializer.ObjectID : this.options.pk;
this.forceServerObjectId = this.options.forceServerObjectId != null ? this.options.forceServerObjectId : false;
// Added strict
this.strict = this.options.strict == null ? false : this.options.strict;
this.notReplied ={};
Expand Down
Loading

0 comments on commit 0f50277

Please sign in to comment.