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

Method handleShowIndexesQuery

src/dialects/mssql/query.js:350–383  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

348 }
349
350 handleShowIndexesQuery(data) {
351 // Group by index name, and collect all fields
352 data = data.reduce((acc, item) => {
353 if (!(item.index_name in acc)) {
354 acc[item.index_name] = item;
355 item.fields = [];
356 }
357
358 item.index_keys.split(',').forEach(column => {
359 let columnName = column.trim();
360 if (columnName.includes('(-)')) {
361 columnName = columnName.replace('(-)', '');
362 }
363
364 acc[item.index_name].fields.push({
365 attribute: columnName,
366 length: undefined,
367 order: column.includes('(-)') ? 'DESC' : 'ASC',
368 collate: undefined
369 });
370 });
371 delete item.index_keys;
372 return acc;
373 }, {});
374
375 return _.map(data, item => ({
376 primary: item.index_name.toLowerCase().startsWith('pk'),
377 fields: item.fields,
378 name: item.index_name,
379 tableName: undefined,
380 unique: item.index_description.toLowerCase().includes('unique'),
381 type: undefined
382 }));
383 }
384
385 handleInsertQuery(results, metaData) {
386 if (this.instance) {

Callers 1

formatResultsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected