Skip to content

Commit

Permalink
Merge pull request mongodb#233 from jeremys/master
Browse files Browse the repository at this point in the history
Add support for the background option when creating an Index.
  • Loading branch information
christkv committed May 31, 2011
2 parents 74d4b52 + 670aa2d commit 0e49c1a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/mongodb/commands/db_command.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ DbCommand.createCreateIndexCommand = function(db, collectionName, fieldOrSpec, o
var indexes = [];
var keys;
var sparse;
var background;

// If the options is a hash
if(options instanceof Object) {
finalUnique = options['unique'] != null ? options['unique'] : false;
sparse = options['sparse'] != null ? options['sparse'] : false;
background = options['background'] != null ? options['background'] : false;
}

// Get all the fields accordingly
Expand Down Expand Up @@ -157,7 +159,8 @@ DbCommand.createCreateIndexCommand = function(db, collectionName, fieldOrSpec, o
// Build the selector
var selector = {'ns':(db.databaseName + "." + collectionName), 'key':fieldHash, 'name':indexName};
selector['unique'] = finalUnique;
selector['sparse'] = sparse;
selector['sparse'] = sparse;
selector['background'] = background;
// Create the insert command for the index and return the document
return new InsertCommand(db, db.databaseName + "." + DbCommand.SYSTEM_INDEX_COLLECTION, false).add(selector);
};
Expand Down

0 comments on commit 0e49c1a

Please sign in to comment.