MCPcopy
hub / github.com/sequelize/sequelize / upsert

Method upsert

lib/dialects/mysql/query-interface.js:44–54  ·  view source on GitHub ↗

* @override

(tableName, insertValues, updateValues, where, options)

Source from the content-addressed store, hash-verified

42 * @override
43 */
44 async upsert(tableName, insertValues, updateValues, where, options) {
45 options = { ...options };
46
47 options.type = QueryTypes.UPSERT;
48 options.updateOnDuplicate = Object.keys(updateValues);
49 options.upsertKeys = Object.values(options.model.primaryKeys).map(item => item.field);
50
51 const model = options.model;
52 const sql = this.queryGenerator.insertQuery(tableName, insertValues, model.rawAttributes, options);
53 return await this.sequelize.query(sql, options);
54 }
55
56 /**
57 * @override

Callers

nothing calls this directly

Calls 2

insertQueryMethod · 0.80
queryMethod · 0.45

Tested by

no test coverage detected