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

Method handleShowIndexesQuery

lib/dialects/snowflake/query.js:281–307  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

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

Callers 1

formatResultsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected