MCPcopy
hub / github.com/sequelize/sequelize / addIndex

Method addIndex

lib/dialects/abstract/query-interface.js:548–565  ·  lib/dialects/abstract/query-interface.js::QueryInterface.addIndex

* Add an index to a column * * @param {string|object} tableName Table name to add index on, can be a object with schema * @param {Array} [attributes] Use options.fields instead, List of attributes to add index on * @param {object} options indexes options * @param {Arr

(tableName, attributes, options, rawTablename)

Source from the content-addressed store, hash-verified

546 * @returns {Promise}
547 */
548 async addIndex(tableName, attributes, options, rawTablename) {
549 class="cm">// Support for passing tableName, attributes, options or tableName, options (with a fields param which is the attributes)
550 if (!Array.isArray(attributes)) {
551 rawTablename = options;
552 options = attributes;
553 attributes = options.fields;
554 }
555
556 if (!rawTablename) {
557 class="cm">// Map for backwards compat
558 rawTablename = tableName;
559 }
560
561 options = Utils.cloneDeep(options);
562 options.fields = attributes;
563 const sql = this.queryGenerator.addIndexQuery(tableName, options, rawTablename);
564 return await this.sequelize.query(sql, { ...options, supportsSearchPath: false });
565 }
566
567 /**
568 * Show indexes on a table

Callers 5

testFunction · 0.80
User.tsFile · 0.80
syncMethod · 0.80

Calls 2

addIndexQueryMethod · 0.80
queryMethod · 0.45

Tested by 1

testFunction · 0.64