Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getOperator (operator, opts) {
opts || (opts = {});
opts.operators || (opts.operators = {});
let ownOps = this.operators || {};
return utils.isUndefined(opts.operators[operator]) ? ownOps[operator] || OPERATORS[operator] : opts.operators[operator];
}
});
.then((ids) => {
const id = utils.isUndefined(props[idAttribute]) ? (ids.length ? ids[0] : undefined) : props[idAttribute]
if (utils.isUndefined(id)) {
throw new Error('Failed to create!')
}
return this._find(mapper, id, opts).then((result) => [result[0], { ids }])
})
},
getKind (mapper, opts) {
opts || (opts = {});
return utils.isUndefined(opts.kind) ? (utils.isUndefined(mapper.kind) ? mapper.name : mapper.kind) : opts.kind;
},
getEndpoint (mapper, id, opts) {
opts || (opts = {})
opts.params = utils.isUndefined(opts.params) ? {} : opts.params
const relationList = mapper.relationList || []
let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint
relationList.forEach((def) => {
if (def.type !== 'belongsTo' || !def.parent) {
return
}
let item
const parentKey = def.foreignKey
const parentDef = def.getRelation()
let parentId = opts.params[parentKey]
if (parentId === false || !parentKey || !parentDef) {
if (parentId === false) {
delete opts.params[parentKey]
}
return false
} else {
getEndpoint (mapper, id, opts) {
opts || (opts = {})
opts.params = utils.isUndefined(opts.params) ? {} : opts.params
const relationList = mapper.relationList || []
let endpoint = utils.isUndefined(opts.endpoint) ? (utils.isUndefined(mapper.endpoint) ? mapper.name : mapper.endpoint) : opts.endpoint
relationList.forEach((def) => {
if (def.type !== 'belongsTo' || !def.parent) {
return
}
let item
const parentKey = def.foreignKey
const parentDef = def.getRelation()
let parentId = opts.params[parentKey]
if (parentId === false || !parentKey || !parentDef) {
if (parentId === false) {
delete opts.params[parentKey]
}
waitForDb (opts) {
opts || (opts = {})
const db = utils.isUndefined(opts.db) ? this.rOpts.db : opts.db
if (!this.databases[db]) {
this.databases[db] = this.r.branch(
this.r.dbList().contains(db),
true,
this.r.dbCreate(db)
).run()
}
return this.databases[db]
},
.then((ids) => {
const id = utils.isUndefined(props[idAttribute]) ? (ids.length ? ids[0] : undefined) : props[idAttribute]
if (utils.isUndefined(id)) {
throw new Error('Failed to create!')
}
return this._find(mapper, id, opts).then((result) => [result[0], { ids }])
})
},
selectTable (mapper, opts) {
opts || (opts = {})
const query = utils.isUndefined(opts.query) ? this.knex : opts.query
const table = this.getTable(mapper)
return query.select(`${table}.*`).from(table)
}
})
records.forEach((record, i) => {
if (!record) {
return;
}
const id = utils.get(record, idAttribute);
if (!utils.isUndefined(id)) {
utils.deepMixIn(record, props[i]);
entities.push({
method: 'update',
key: this.datastore.key([this.getKind(mapper, opts), id]),
data: record
});
_records.push(record);
}
});
if (!_records.length) {
getOperator (operator, opts) {
opts || (opts = {})
opts.operators || (opts.operators = {})
let ownOps = this.operators || {}
return utils.isUndefined(opts.operators[operator]) ? ownOps[operator] : opts.operators[operator]
},