Skip to content

noahbjohnson/generate-bigquery-schema

Repository files navigation

generate-bigquery-schema

FOSSA Status

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

  1. git clone https://github.com/trinity-insight/generate-bigquery-schema.git
  2. npm install

Building to JS

  1. npm run build

Linting (StandardJS)

  1. npm run lint

Testing (Mocha)

  1. npm test

License

FOSSA Status

About

Generate a BigQuery schema from an object or array of objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •