* Update multiple records of a table * * @example * queryInterface.bulkUpdate('roles', { * label: 'admin', * }, { * userType: 3, * }, * ); * * @param {string} tableName Table name to update * @param {object} values Values to be inserted, mapped
(tableName, values, identifier, options, attributes)
| 895 | * @returns {Promise} |
| 896 | */ |
| 897 | async bulkUpdate(tableName, values, identifier, options, attributes) { |
| 898 | options = Utils.cloneDeep(options); |
| 899 | if (typeof identifier === 'object') identifier = Utils.cloneDeep(identifier); |
| 900 | |
| 901 | const sql = this.queryGenerator.updateQuery(tableName, values, identifier, options, attributes); |
| 902 | const table = _.isObject(tableName) ? tableName : { tableName }; |
| 903 | const model = _.find(this.sequelize.modelManager.models, { tableName: table.tableName }); |
| 904 | |
| 905 | options.type = QueryTypes.BULKUPDATE; |
| 906 | options.model = model; |
| 907 | return await this.sequelize.query(sql, options); |
| 908 | } |
| 909 | |
| 910 | async delete(instance, tableName, identifier, options) { |
| 911 | const cascades = []; |