npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

schema-to-sql

0.1.0

@tjholowaychuk

npmHomeRepoSnykSocket
Downloads:10
$ npm install schema-to-sql
DailyWeeklyMonthlyYearly

schema-to-sql

Generate create table statements out of auto-schema objects, pretty specific to our needs and probably not useful to you ;D

Installation

$ npm install schema-to-sql

Example

var sql = require('schema-to-sql');

var schema = { action: 'varchar',
  version: 'float',
  timestamp: 'timestamp',
  channel: 'varchar',
  sessionId: 'varchar',
  userId: 'varchar',
  event: 'varchar',
  'properties.url': 'varchar',
  'properties.referrer': 'varchar',
  'properties.userAgent': 'varchar',
  'context.language': 'varchar',
  'context.library': 'varchar',
  'userAgent.family': 'varchar',
  'userAgent.major': 'varchar',
  'userAgent.minor': 'varchar',
  'userAgent.os': 'varchar',
  'userAgent.device': 'varchar',
  'userAgent.userAgent': 'varchar',
  'referrer.type': 'varchar',
  projectId: 'varchar' };

console.log(sql(schema));

yields:

create table users(
  action varchar(2048),
  version float,
  timestamp timestamp,
  channel varchar(2048),
  sessionId varchar(2048),
  userId varchar(2048),
  event varchar(2048),
  "properties.url" varchar(2048),
  "properties.referrer" varchar(2048),
  "properties.userAgent" varchar(2048),
  "context.language" varchar(2048),
  "context.library" varchar(2048),
  "userAgent.family" varchar(2048),
  "userAgent.major" varchar(2048),
  "userAgent.minor" varchar(2048),
  "userAgent.os" varchar(2048),
  "userAgent.device" varchar(2048),
  "userAgent.userAgent" varchar(2048),
  "referrer.type" varchar(2048),
  projectId varchar(2048));

License

MIT