A tool for documenting and working with related data
See our examples/software
for more details...
orm:
singular: Repository
plural: Repositories
relations:
- local_property: components
joins:
- schema: component.schema.yaml
local_key: name
foreign_key: repository_name
type: many
type: object
properties:
name:
type: string
type:
type: string
enum:
- git
- subversion
- cvs
checkout:
type: object
properties:
web:
type: string
format: uri
ssh:
type: string
format: uri
required: [ web ]
required: [ name, type, checkout ]
additionalProperties: false
Name | Description |
---|---|
orm | ORM Definition |
properties | Object Properties |
Name | Description |
---|---|
singular | Singular model name (Repository) |
plural | Plural collection name (Repositories) |
primary_property | Primary field name (name) |
relations | Defined relations |
Name | Description |
---|---|
local_property | Local property to alias the relationship to |
joins | How to find relations |
Name | Description |
---|---|
schema | Name of the schema file which contains the object |
local_key | Name of the local property for the relation |
foreign_key | Name of the foreign property for the relation |
type | What type of join, one or many |
Path | Contents |
---|---|
project |
Contains your project's files |
project/schemas |
Contains your project schemas |
project/data |
Contains your project's data |
project/bundle/schemas.json |
Your bundled schema definitions |
- Create your
project
,project/data
,project/schemas
andproject/bundle
directories. - Add your schemas and data (refer to
examples/software
for examples) - Validate your schemas with
./bin/cli.js -p <path to project> validate schemas
and./bin/cli.js -p <path to project> validate data
- Bundle your schemas with
./bin/cli.js -p <path to project> bundle <path to project>/bundle/schemas.json
- Load your schemas and data, for the win!
const path = require('path')
const JS_ORM = require('../../../index')
const _ = require('underscore')
const projectSchemasFile = path.resolve(__dirname, '..', 'bundle/schemas.json')
const dataPath = path.resolve(__dirname, '..', 'data')
const loader = new JS_ORM.Loader()
const orm = loader.loadSchemas(projectSchemasFile)
loader.loadData(dataPath)
// simple get
// returns: { name: 'Core API', reposiotry_name: 'Core Project' }
console.log(orm.getRepository('component').get('Core API'))
Options: meta-schema, schemas, data
Example: ./bin/cli.js -p examples/software validate schemas
Example: ./bin/cli.js -p examples/software bundle examples/software/bundle/schemas.json
Example: ./bin/cli.js -p examples/software diagram && open test.png
git clone https://github.com/jmather/json-schema-orm
cd json-schema-orm
cd browser
npm install && npm install -g gulp
gulp