Comparing version 2.0.4 to 2.1.0
{ | ||
"name": "leoric", | ||
"version": "2.0.4", | ||
"version": "2.1.0", | ||
"description": "JavaScript Object-relational mapping alchemy", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -260,2 +260,13 @@ 'use strict'; | ||
/** | ||
* see https://github.com/sequelize/sequelize/blob/a729c4df41fa3a58fbecaf879265d2fb73d80e5f/src/model.js#L2299 | ||
* @param {Array<Object>} valueSets | ||
* @param {Object} options | ||
* @returns | ||
*/ | ||
static bulkBuild(valueSets, options = {}) { | ||
if (!valueSets.length) return []; | ||
return valueSets.map(value => this.build(value, options)); | ||
} | ||
// EXISTS | ||
@@ -312,3 +323,5 @@ // static bulkCreate() {} | ||
const { where, force } = options; | ||
return await this.remove(where || {}, force, { ...options }); | ||
const spell = this._remove(where || {}, force, { ...options }); | ||
translateOptions(spell, options); | ||
return spell; | ||
} | ||
@@ -315,0 +328,0 @@ |
@@ -792,3 +792,3 @@ 'use strict'; | ||
} | ||
return await Model.remove(condition, forceDelete, { hooks: false, ...opts }); | ||
return await Model._remove(condition, forceDelete, opts); | ||
} | ||
@@ -1458,2 +1458,20 @@ | ||
static remove(conditions, forceDelete = false, options) { | ||
return this._remove(conditions, forceDelete, options); | ||
} | ||
/** | ||
* private method for internal calling | ||
* Remove any record that matches `conditions`. | ||
* - If `forceDelete` is true, `DELETE` records from database permanently. | ||
* - If not, update `deletedAt` attribute with current date. | ||
* - If `forceDelete` isn't true and `deleteAt` isn't around, throw an Error. | ||
* @example | ||
* Post.remove({ title: 'Leah' }) // mark Post { title: 'Leah' } as deleted | ||
* Post.remove({ title: 'Leah' }, true) // delete Post { title: 'Leah' } | ||
* Post.remove({}, true) // delete all data of posts | ||
* @param {Object} conditions | ||
* @param {boolean} forceDelete | ||
* @return {Spell} | ||
*/ | ||
static _remove(conditions, forceDelete = false, options) { | ||
const { deletedAt } = this.timestamps; | ||
@@ -1460,0 +1478,0 @@ if (forceDelete !== true && this.attributes[deletedAt]) { |
@@ -78,2 +78,17 @@ 'use strict'; | ||
}, | ||
/** | ||
* DELETE ... ORDER BY ...LIMIT | ||
* @param {Spell} spell | ||
*/ | ||
formatDelete(spell) { | ||
const result = spellbook.formatDelete.call(this, spell); | ||
const { rowCount, orders } = spell; | ||
const chunks = []; | ||
if (orders.length > 0) chunks.push(`ORDER BY ${this.formatOrders(spell, orders).join(', ')}`); | ||
if (rowCount > 0) chunks.push(`LIMIT ${rowCount}`); | ||
if (chunks.length > 0) result.sql += ` ${chunks.join(' ')}`; | ||
return result; | ||
} | ||
}; |
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
7986
268000
49