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

Method addIndex

src/dialects/abstract/query-interface.js:570–587  ·  view source on GitHub ↗

* 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

568 * @returns {Promise}
569 */
570 async addIndex(tableName, attributes, options, rawTablename) {
571 // Support for passing tableName, attributes, options or tableName, options (with a fields param which is the attributes)
572 if (!Array.isArray(attributes)) {
573 rawTablename = options;
574 options = attributes;
575 attributes = options.fields;
576 }
577
578 if (!rawTablename) {
579 // Map for backwards compat
580 rawTablename = tableName;
581 }
582
583 options = Utils.cloneDeep(options);
584 options.fields = attributes;
585 const sql = this.queryGenerator.addIndexQuery(tableName, options, rawTablename);
586 return await this.sequelize.query(sql, { ...options, supportsSearchPath: false });
587 }
588
589 /**
590 * Show indexes on a table

Callers 6

testFunction · 0.80
User.tsFile · 0.80
syncMethod · 0.80

Calls 2

addIndexQueryMethod · 0.45
queryMethod · 0.45

Tested by 1

testFunction · 0.64