10 examples of 'sequelize delete' in JavaScript

Every line of 'sequelize delete' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
90delete(id, key) {
91 const data = this.items.get(id) || {};
92 delete data[key];
93
94 if (this.dataColumn) {
95 return this.table.upsert({
96 [this.idColumn]: id,
97 [this.dataColumn]: data
98 });
99 }
100
101 return this.table.upsert({
102 [this.idColumn]: id,
103 [key]: null
104 });
105}
111async delete(softDeletes) {
112 if (softDeletes) {
113 return this.attributes['delete']();
114 }
115 return this.attributes.remove();
116}
504async delete(options) {
505 options = await this.parseOptions(options);
506 options = await this.beforeDelete(options);
507 const rows = await this.db().delete(options);
508 await this.afterDelete(options);
509 return rows;
510}
195deleteAsync() {
196 return client.transaction(transaction =>
197 this._getOriginal().destroy({ transaction })
198 );
199}
16async delete (id) {
17 return this.database.delete(id)
18}
479async delete(options) {
480 try {
481 let parsedOptions = await helper.parseOptions(this, options);
482 if (lib.isEmpty(parsedOptions.where)) {
483 return this.error('_OPERATION_WRONG_');
484 }
485 // init db
486 let db = await this.initDB();
487 await this._beforeDelete(parsedOptions);
488 let result = await db.delete(parsedOptions);
489 await this._afterDelete(parsedOptions);
490 return result || [];
491 } catch (e) {
492 return this.error(e);
493 }
494}
56async delete(softDeletes: boolean): Promise {
57 if (softDeletes && this.softDeletesSetting) {
58 this.setAttribute(this.softDeletesSetting.deletedAt, Moment().toDate())
59 return this.save(false)
60 }
61
62 if (!softDeletes && !this.isNew()) {
63 const primaryKey = this.getPrimaryKeyName()
64 return this.collection.deleteOne({ [primaryKey]: this.attributes.getAttribute(primaryKey) })
65 }
66}
20deleteById(id) {
21 for (let index in this.baseModels) {
22 if (this.baseModels[index]['id'] === id) {
23 this.baseModels.splice(index, 1);
24 }
25 }
26 return;
27}
97public async remove(key: string): Promise
98{
99 if (typeof key === 'undefined') throw new TypeError('Key must be provided');
100 if (typeof key !== 'string') throw new TypeError('Key must be a string');
101 await this._model.destroy({ where: { key } });
102}
114delete(type, object, ...listenerArgs) {
115 // Test if the object is a RealmObject by checking if it has the function objectSchema(). If it
116 // is, stick it in an array. Otherwise, objet is an array, a realm list, or a realm results
117 // object, so just slice it to make sure it is a simple array
118 const objects = typeof object.objectSchema === 'function' ? [object] : object.slice();
119
120 // If empty, ignore
121 if (!objects || objects.length === 0) return;
122
123 // Go through each object, call its destructor, and alert any change listeners
124 objects.forEach(obj => {
125 const record = { id: obj.id }; // If it is being deleted, only alert with the id
126 if (obj && obj.destructor instanceof Function) obj.destructor(this);
127 this.alertListeners(CHANGE_TYPES.DELETE, type, record, ...listenerArgs);
128 });
129
130 // Actually delete the objects from the database
131 this.realm.delete(objects);
132}

Related snippets