* Delete multiple records from a table * * @param {string} tableName table name from where to delete records * @param {object} where where conditions to find records to delete * @param {object} [options] options * @param {boolean} [options.trunc
(tableName, where, options, model)
| 977 | * @returns {Promise} |
| 978 | */ |
| 979 | async bulkDelete(tableName, where, options, model) { |
| 980 | options = Utils.cloneDeep(options); |
| 981 | options = _.defaults(options, { limit: null }); |
| 982 | |
| 983 | if (options.truncate === true) { |
| 984 | return this.sequelize.query( |
| 985 | this.queryGenerator.truncateTableQuery(tableName, options), |
| 986 | options |
| 987 | ); |
| 988 | } |
| 989 | |
| 990 | if (typeof identifier === 'object') where = Utils.cloneDeep(where); |
| 991 | |
| 992 | return await this.sequelize.query( |
| 993 | this.queryGenerator.deleteQuery(tableName, where, options, model), |
| 994 | options |
| 995 | ); |
| 996 | } |
| 997 | |
| 998 | async select(model, tableName, optionsArg) { |
| 999 | const options = { ...optionsArg, type: QueryTypes.SELECT, model }; |