https://github.com/wmfs/relationize
Takes a set of JSON Schema definitions and returns a relational database structure capable of storing compliant data.
https://github.com/wmfs/relationize
package postgresql tymly
Last synced: 11 months ago
JSON representation
Takes a set of JSON Schema definitions and returns a relational database structure capable of storing compliant data.
- Host: GitHub
- URL: https://github.com/wmfs/relationize
- Owner: wmfs
- License: mit
- Created: 2018-06-11T09:27:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-06-29T23:34:59.000Z (about 1 year ago)
- Last Synced: 2025-07-06T06:46:50.615Z (12 months ago)
- Topics: package, postgresql, tymly
- Language: JavaScript
- Homepage:
- Size: 386 KB
- Stars: 2
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# relationize
[](https://tymly.io/)
[](https://www.npmjs.com/package/@wmfs/relationize)
[](https://circleci.com/gh/wmfs/relationize)
[](https://codecov.io/gh/wmfs/relationize)
[](https://www.codefactor.io/repository/github/wmfs/relationize)
[](https://dependabot.com/)
[](http://commitizen.github.io/cz-cli/)
[](https://standardjs.com)
[](https://github.com/wmfs/tymly/blob/master/packages/pg-concat/LICENSE)
> Takes a set of JSON Schema definitions and returns a relational database structure capable of storing compliant data.
## Install
```bash
$ npm install relationize --save
```
```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.
}
)
```
### relationize(options, callback)
### Options:
| Option | Type | Notes |
| ------ | ----- | ------ |
| `source` | `object` | A `source` object for configuring where to derive JSON Schema data from.
### `source` object
__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](https://www.npmjs.com/package/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)
Relationize returns objects of the same form as those returned by the __[pg-info](https://github.com/wmfs/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](https://github.com/wmfs/tymly/tree/master/packages/pg-info) for more details.__
```bash
$ npm test
```
## License
[MIT](https://github.com/wmfs/relationize/blob/master/LICENSE)