Created
September 15, 2018 22:02
-
-
Save goodpic/1b010b63e739b584b8b2805d5628f02c to your computer and use it in GitHub Desktop.
Commander.js command line to create a new BigQuery table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const program = require('commander'); | |
const { createTable } = require('../src/bigquery'); | |
const { SchemaSalesByHour } = require('../schemas/SchemaSalesByHour'); | |
program | |
.version('0.1.0') | |
.option('-t, --table [table]', 'Specify the table to create', '') | |
.parse(process.argv); | |
if (program.table) { | |
console.log(`Create a new table ${program.table}`); | |
switch (program.table) { | |
case 'shop_sales_by_hour': | |
createTable({ | |
datasetId: 'stats', | |
tableId: program.table, | |
schema: SchemaSalesByHour, | |
isTest: false, | |
}).then(() => console.log(`${program.table} created.`)); | |
break; | |
default: | |
console.log(`Cannot find the database ${program.table}`); | |
} | |
} else { | |
console.log('Please specifiy the table to create by "-t TABLE_NAME"'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment