Takes a set of JSON Schema definitions and returns a relational database structure capable of storing compliant data.
npm install @wmfs/relationize
> Takes a set of JSON Schema definitions and returns a relational database structure capable of storing compliant data.
bash
$ npm install relationize --save
`Usage
`javascript
const relationize = require('relationize') relationize (
{
source: {
paths: [
{
namespace: 'relationizeTest',
path: '/somewhere/json-schemas/live'
}
]
}
},
function (err, dbStructure) {
// Done!
// - The value of 'dbStructure' takes the same form
// as the output generated by the 'pg-info' package.
}
)
`API
$3
$3
| Option | Type | Notes |
| ------ | ----- | ------ |
| source | object | A source object for configuring where to derive JSON Schema data from.$3
__Examples__
* From files:
`javascript
{
paths: [
{
namespace: 'relationizeTest',
path: '/somewhere/json-schemas/live'
}
]
}
`* From Javascript object:
`javascript
{
schemas: [
{
namespace: 'relationizeTest',
schema: {
// JSON schema here
}
}
]
}
`__Properties__
| property | Type | Notes |
| -------- | ----- | ----- |
|
paths | [object] | An array of objects containing a namespace property (used to separate related tables into schemas_ and path (a file-path from where to load JSON files from - uses glob, so the ** pattern is supported)
| schemas | [object] | An array of objects containing a namespace property (used to separate related tables into schemas_ and schema (a ready-to-use JSON Schema)Output
Relationize returns objects of the same form as those returned by the __pg-info__ package.
The output of Relationize can then be used to generate a relational database (complete with comments, tables, indexes and foreign key constraints) to store your JSON-structured data.
* __Please refer to the pg-info docs for more details.__
Testing
`bash
$ npm test
``