MCPcopy
hub / github.com/sequelize/sequelize / handleShowIndexesQuery

Method handleShowIndexesQuery

lib/dialects/mysql/query.js:271–297  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

269 }
270
271 handleShowIndexesQuery(data) {
272 // Group by index name, and collect all fields
273 data = data.reduce((acc, item) => {
274 if (!(item.Key_name in acc)) {
275 acc[item.Key_name] = item;
276 item.fields = [];
277 }
278
279 acc[item.Key_name].fields[item.Seq_in_index - 1] = {
280 attribute: item.Column_name,
281 length: item.Sub_part || undefined,
282 order: item.Collation === 'A' ? 'ASC' : undefined
283 };
284 delete item.column_name;
285
286 return acc;
287 }, {});
288
289 return _.map(data, item => ({
290 primary: item.Key_name === 'PRIMARY',
291 fields: item.fields,
292 name: item.Key_name,
293 tableName: item.Table,
294 unique: item.Non_unique !== 1,
295 type: item.Index_type
296 }));
297 }
298}
299
300module.exports = Query;

Callers 1

formatResultsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected