0.1.4 • Published 7 years ago
@sql-extra/createtable v0.1.4
@sql-extra/createtable
Generate SQL command for CREATE TABLE.
const createTable = require('@sql-extra/createtable');
// createTable(<name>, <columns>, [options])
// -> sql command
// options: {
// pk: null // primary key: none
// }
createTable('plant', {name: 'TEXT', type: 'TEXT', age: 'INT'});
// CREATE TABLE IF NOT EXISTS "plant" ("name" TEXT, "type" TEXT, "age" INT);
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"));