-
Notifications
You must be signed in to change notification settings - Fork 1
createIndex
Subhajit Sahu edited this page Feb 12, 2020
·
2 revisions
Generates SQL command for CREATE INDEX.
sql.createIndex(name, table, expression, [options]);
// name: index name
// table: table name
// expression: index expression
// options: options {method}
// .method: index method (null => btree)
const sql = require('extra-sql');
sql.createIndex('food_code_idx', 'food', `"code"`);
// CREATE INDEX IF NOT EXISTS "food_code_idx" ON "food" ("code");
sql.createIndex('food_type_idx', 'food', `"type"`, {method: 'GIN'});
// CREATE INDEX IF NOT EXISTS "food_type_idx" ON "food" USING GIN ("type");