* 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)
| 954 | * @returns {Promise} |
| 955 | */ |
| 956 | async bulkDelete(tableName, where, options, model) { |
| 957 | options = Utils.cloneDeep(options); |
| 958 | options = _.defaults(options, { limit: null }); |
| 959 | |
| 960 | if (options.truncate === true) { |
| 961 | return this.sequelize.query( |
| 962 | this.queryGenerator.truncateTableQuery(tableName, options), |
| 963 | options |
| 964 | ); |
| 965 | } |
| 966 | |
| 967 | if (typeof identifier === 'object') where = Utils.cloneDeep(where); |
| 968 | |
| 969 | return await this.sequelize.query( |
| 970 | this.queryGenerator.deleteQuery(tableName, where, options, model), |
| 971 | options |
| 972 | ); |
| 973 | } |
| 974 | |
| 975 | async select(model, tableName, optionsArg) { |
| 976 | const options = { ...optionsArg, type: QueryTypes.SELECT, model }; |