@colucom/osseus-mongo
Advanced tools
Comparing version 2.0.2 to 2.0.3
const mongoose = require('mongoose') | ||
const getOptions = (config) => { | ||
const defaultOptions = { | ||
keepAlive: 1, | ||
connectTimeoutMS: 30000, | ||
socketTimeoutMS: 30000, | ||
useUnifiedTopology: true, | ||
useCreateIndex: true, | ||
useFindAndModify: false | ||
} | ||
const getOptions = config => { | ||
// if mongoose options object isn't null and isn't empty, return options object | ||
if (config && config.options && !(Object.keys(config.options).length === 0 && config.options.constructor === Object)) { | ||
return config.options | ||
if ( | ||
config && | ||
config.options && | ||
!(Object.keys(config.options).length === 0 && config.options.constructor === Object) | ||
) { | ||
return { ...defaultOptions, ...config.options } | ||
} else { | ||
// these are default options | ||
return { | ||
keepAlive: 1, | ||
connectTimeoutMS: 30000, | ||
socketTimeoutMS: 30000, | ||
useUnifiedTopology: true, | ||
useCreateIndex: true, | ||
useFindAndModify: false | ||
} | ||
return defaultOptions | ||
} | ||
@@ -29,8 +35,6 @@ } | ||
mongoose.Promise = global.Promise | ||
const db = await mongoose.createConnection(config.osseus_mongo.uri, {...options, useNewUrlParser: true}) | ||
//db.mongoose = mongoose | ||
const db = await mongoose.createConnection(config.osseus_mongo.uri, { ...options, useNewUrlParser: true }) | ||
resolve(db) | ||
}) | ||
} |
{ | ||
"name": "@colucom/osseus-mongo", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Osseus mongo", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9192
45