Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function HttpAdapter (opts) {
utils.classCallCheck(this, HttpAdapter)
opts || (opts = {})
// Fill in any missing options with the defaults
utils.fillIn(opts, DEFAULTS)
Adapter.call(this, opts)
}
* @name MongoDBAdapter#findOneOpts
* @type {object}
* @default {}
*/
this.findOneOpts || (this.findOneOpts = {})
utils.fillIn(this.findOneOpts, FIND_ONE_OPTS_DEFAULTS)
/**
* Default options to pass to collection#insert.
*
* @name MongoDBAdapter#insertOpts
* @type {object}
* @default {}
*/
this.insertOpts || (this.insertOpts = {})
utils.fillIn(this.insertOpts, INSERT_OPTS_DEFAULTS)
/**
* Default options to pass to collection#insertMany.
*
* @name MongoDBAdapter#insertManyOpts
* @type {object}
* @default {}
*/
this.insertManyOpts || (this.insertManyOpts = {})
utils.fillIn(this.insertManyOpts, INSERT_MANY_OPTS_DEFAULTS)
/**
* Default options to pass to collection#update.
*
* @name MongoDBAdapter#updateOpts
* @type {object}
return this._run((client, success, failure) => {
const collectionId = this._getCollectionId(mapper, opts)
const removeOpts = this.getOpt('removeOpts', opts)
utils.fillIn(removeOpts, this.getQueryOptions(mapper, query))
const mongoQuery = this.getQuery(mapper, query)
const collection = client.collection(collectionId)
const handler = (err, cursor) => err ? failure(err) : success(cursor)
if (collection.deleteMany) {
collection
.deleteMany(mongoQuery, removeOpts, handler)
} else {
collection
.remove(mongoQuery, removeOpts, handler)
}
}).then((cursor) => {
cursor.connection = undefined
export function SqlAdapter (opts) {
utils.classCallCheck(this, SqlAdapter)
opts || (opts = {})
opts.knexOpts || (opts.knexOpts = {})
utils.fillIn(opts, DEFAULTS)
Object.defineProperty(this, 'knex', {
writable: true,
value: undefined
})
Adapter.call(this, opts)
/**
* Override the default predicate functions for specified operators.
*
* @name SqlAdapter#operators
* @type {Object}
* @default {}
*/
this.knex || (this.knex = knex(this.knexOpts))
* @name MongoDBAdapter#insertManyOpts
* @type {object}
* @default {}
*/
this.insertManyOpts || (this.insertManyOpts = {})
utils.fillIn(this.insertManyOpts, INSERT_MANY_OPTS_DEFAULTS)
/**
* Default options to pass to collection#update.
*
* @name MongoDBAdapter#updateOpts
* @type {object}
* @default {}
*/
this.updateOpts || (this.updateOpts = {})
utils.fillIn(this.updateOpts, UPDATE_OPTS_DEFAULTS)
/**
* Default options to pass to collection#destroy.
*
* @name MongoDBAdapter#removeOpts
* @type {object}
* @default {}
*/
this.removeOpts || (this.removeOpts = {})
utils.fillIn(this.removeOpts, REMOVE_OPTS_DEFAULTS)
this.client = new utils.Promise((resolve, reject) => {
MongoClient.connect(opts.uri, opts.mongoDriverOpts, (err, client) => {
if (err) {
return reject(err)
}
*
* @name SqlAdapter#operators
* @type {Object}
* @default {}
*/
this.knex || (this.knex = knex(this.knexOpts))
/**
* Override the default predicate functions for specified operators.
*
* @name SqlAdapter#operators
* @type {Object}
* @default {}
*/
this.operators || (this.operators = {})
utils.fillIn(this.operators, OPERATORS)
}
* @name RethinkDBAdapter#deleteOpts
* @type {object}
* @default {}
*/
this.deleteOpts || (this.deleteOpts = {})
utils.fillIn(this.deleteOpts, DELETE_OPTS_DEFAULTS)
/**
* Default options to pass to r#run.
*
* @name RethinkDBAdapter#runOpts
* @type {object}
* @default {}
*/
this.runOpts || (this.runOpts = {})
utils.fillIn(this.runOpts, RUN_OPTS_DEFAULTS)
/**
* Override the default predicate functions for the specified operators.
*
* @name RethinkDBAdapter#operators
* @type {object}
* @default {}
*/
this.operators || (this.operators = {})
utils.fillIn(this.operators, OPERATORS)
/**
* Options to pass to a new `rethinkdbdash` instance, if one was not provided
* at {@link RethinkDBAdapter#r}. See the [rethinkdbdash README][readme] for
* instance options.
*
* const adapter = new RethinkDBAdapter({
* rOpts: {
* servers: [
* { host: '192.168.0.100', port: 28015 },
* { host: '192.168.0.101', port: 28015 },
* { host: '192.168.0.102', port: 28015 }
* ]
* }
* });
*
* @name RethinkDBAdapter#rOpts
* @see https://github.com/neumino/rethinkdbdash#importing-the-driver
* @type {object}
*/
this.rOpts || (this.rOpts = {})
utils.fillIn(this.rOpts, R_OPTS_DEFAULTS)
this.r || (this.r = rethinkdbdash(this.rOpts))
}
* @name MongoDBAdapter#insertOpts
* @type {object}
* @default {}
*/
this.insertOpts || (this.insertOpts = {})
utils.fillIn(this.insertOpts, INSERT_OPTS_DEFAULTS)
/**
* Default options to pass to collection#insertMany.
*
* @name MongoDBAdapter#insertManyOpts
* @type {object}
* @default {}
*/
this.insertManyOpts || (this.insertManyOpts = {})
utils.fillIn(this.insertManyOpts, INSERT_MANY_OPTS_DEFAULTS)
/**
* Default options to pass to collection#update.
*
* @name MongoDBAdapter#updateOpts
* @type {object}
* @default {}
*/
this.updateOpts || (this.updateOpts = {})
utils.fillIn(this.updateOpts, UPDATE_OPTS_DEFAULTS)
/**
* Default options to pass to collection#destroy.
*
* @name MongoDBAdapter#removeOpts
* @type {object}
* @name MongoDBAdapter#updateOpts
* @type {object}
* @default {}
*/
this.updateOpts || (this.updateOpts = {})
utils.fillIn(this.updateOpts, UPDATE_OPTS_DEFAULTS)
/**
* Default options to pass to collection#destroy.
*
* @name MongoDBAdapter#removeOpts
* @type {object}
* @default {}
*/
this.removeOpts || (this.removeOpts = {})
utils.fillIn(this.removeOpts, REMOVE_OPTS_DEFAULTS)
this.client = new utils.Promise((resolve, reject) => {
MongoClient.connect(opts.uri, opts.mongoDriverOpts, (err, client) => {
if (err) {
return reject(err)
}
this._db = client.db()
resolve(this._db)
})
})
}