# relationize

> Takes a set of JSON Schema definitions and returns a relational database structure capable of storing compliant data.

Latest version **0.0.19** (published 2017-10-06) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install relationize
pnpm add relationize
yarn add relationize
bun add relationize
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.19 |
| Published | 2017-10-06 |
| First published | 2017-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 121 |
| Author | Tim Needham |
| Maintainers | timneedham |
| Keywords | json, schema, pg, postgres |

## Links

- npm: https://www.npmjs.com/package/relationize
- Repository: https://github.com/wmfs/tymly
- Homepage: https://github.com/wmfs/tymly#readme
- Issues: https://github.com/wmfs/tymly/issues
- npm.io page: https://npm.io/package/relationize

## Dependencies (7)

- [boom](https://npm.io/package/boom.md) ^5.2.0
- [glob](https://npm.io/package/glob.md) ^7.1.2
- [async](https://npm.io/package/async.md) ^2.5.0
- [debug](https://npm.io/package/debug.md) ^2.6.8
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [jsonfile](https://npm.io/package/jsonfile.md) ^3.0.1
- [precision](https://npm.io/package/precision.md) ^1.0.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.19 (latest) — 2017-10-06
- 0.0.17 — 2017-08-19
- 0.0.16 — 2017-07-22
- 0.0.15 — 2017-07-19
- 0.0.13 — 2017-07-19
- 0.0.12 — 2017-07-19
- 0.0.11 — 2017-07-08
- 0.0.10 — 2017-07-08
- 0.0.8 — 2017-06-07
- 0.0.7 — 2017-06-04
- 0.0.6 — 2017-06-04
- 0.0.5 — 2017-06-02
- 0.0.3 — 2017-06-02
- 0.0.2 — 2017-05-23
- 0.0.1 — 2017-05-22

## README

# relationize
	
> Takes a set of JSON Schema definitions and returns a relational database structure capable of storing compliant data.

## <a name="install"></a>Install
```bash
$ npm install relationize --save
```

## <a name="usage"></a>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.
    }
  )
```

## <a name="api"></a>API

### 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)



## <a name="output"></a>Output

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/pg-info) for more details.__


## <a name="test"></a>Testing


```bash
$ npm test
```

## <a name="license"></a>License
[MIT](https://github.com/wmfs/relationize/blob/master/LICENSE)

---
_Source: https://npm.io/package/relationize · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
