-
Notifications
You must be signed in to change notification settings - Fork 0
createTable
Subhajit Sahu edited this page Feb 12, 2020
·
4 revisions
Generates SQL command for CREATE TABLE.
sql.createTable(name, columns, [options]);
// name: table name
// columns: columns {name: type}
// options: options {pk}
// .pk: primary key (null => none)
const sql = require('extra-sql');
sql.createTable('plant', {name: 'TEXT', type: 'TEXT', age: 'INT'});
// CREATE TABLE IF NOT EXISTS "plant" ("name" TEXT, "type" TEXT, "age" INT);
sql.createTable('animal', {name: 'TEXT', type: 'TEXT', age: 'INT'}, {pk: 'name'});
// CREATE TABLE IF NOT EXISTS "animal" ("name" TEXT, "type" TEXT, "age" INT, PRIMARY KEY("name"));