Skip to content

Commit

Permalink
allow config promise library for mongoose and mongodb driver
Browse files Browse the repository at this point in the history
  • Loading branch information
gongxiancao committed Mar 21, 2016
1 parent 6b3efc6 commit db85eeb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ function lift (done) {
var self = this;
var modelsConfig = self.config.models;
var connectionName = modelsConfig.connection;
if(modelsConfig.Promise) {
mongoose.Promise = modelsConfig.Promise;
}

var connectionConfig = self.config.connections[connectionName];
if(!connectionConfig) {
throw new Error('No connection config with name ' + connectionName + ' for current env');
Expand Down Expand Up @@ -60,7 +64,11 @@ function lift (done) {
_.extend(global, models);

var connectionString = composeMongodbConnectionString(connectionConfig);
mongoose.connect(connectionString, done);
var options = {};
if(modelsConfig.promise) {
options.promiseLibrary = modelsConfig.promise;
}
mongoose.connect(connectionString, options, done);
});
});
}
Expand Down

0 comments on commit db85eeb

Please sign in to comment.