@trinity-insight/generate-bigquery-schema
v0.1.4
Published
Smart generation of BigQuery schemas from an object or array of objects
Downloads
413
Keywords
Readme
generate-bigquery-schema
Generate a BigQuery schema from an object or array of objects
Uses generate-schema to create individual schemas. This package serves as a wrapper around generate-schema for extensibility and our specific use cases.
Install
npm install @trinity-insight/generate-bigquery-schema
Usage
Single Object
const gbs = require('generate-bigquery-schema')
const singleObject = {
stringKey: "string",
numberKey: 88,
objectKey: {
cool: "we can nest things"
}
}
console.log(gbs.generateSchema(singleObject))
// { fields:
// [ { name: 'stringKey', type: 'STRING', mode: 'NULLABLE' },
// { name: 'numberKey', type: 'INTEGER', mode: 'NULLABLE' },
// { name: 'objectKey',
// type: 'RECORD',
// mode: 'NULLABLE',
// fields: [Array] } ] }
Object Array
const multipleObjects = [
{
foo: 'bar',
number: '4'
},
{
foo: 'bar',
number: 4
}
]
console.log(gbs.generateSchema(multipleObjects))
// { fields:
// [ { type: 'STRING',
// mode: 'NULLABLE',
// description: null,
// name: 'foo' },
// { type: 'INTEGER',
// mode: 'NULLABLE',
// description: null,
// name: 'number' } ] }
Development
Installing
git clone https://github.com/trinity-insight/generate-bigquery-schema.git
npm install
Building to JS
npm run build
Linting (StandardJS)
npm run lint
Testing (Mocha)
npm test