* 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)
| 918 | * @returns {Promise} |
| 919 | */ |
| 920 | async bulkUpdate(tableName, values, identifier, options, attributes) { |
| 921 | options = Utils.cloneDeep(options); |
| 922 | if (typeof identifier === 'object') identifier = Utils.cloneDeep(identifier); |
| 923 | |
| 924 | const sql = this.queryGenerator.updateQuery(tableName, values, identifier, options, attributes); |
| 925 | const table = _.isObject(tableName) ? tableName : { tableName }; |
| 926 | const model = options.model ? options.model : _.find(this.sequelize.modelManager.models, { tableName: table.tableName }); |
| 927 | |
| 928 | options.type = QueryTypes.BULKUPDATE; |
| 929 | options.model = model; |
| 930 | return await this.sequelize.query(sql, options); |
| 931 | } |
| 932 | |
| 933 | async delete(instance, tableName, identifier, options) { |
| 934 | const cascades = []; |