Schema
define the structure of your data, schema specific methods, indexes / constrains, hooks, validation, relationships,
Constructor Summary
| Public Constructor | ||
| public |
constructor(object: *, options: *) Used to initialize a new schema. |
|
Member Summary
| Public Members | ||
| public |
methods: * |
|
| public |
|
|
Method Summary
| Public Methods | ||
| public |
relationsship(rel: function) Adds an instance relationship to documents constructed from Models compiled from this schema. |
|
| public |
Function to use for validating a node |
|
Public Constructors
public constructor(object: *, options: *) source
Used to initialize a new schema.
Params:
| Name | Type | Attribute | Description |
| object | * | ||
| options | * |
Example:
import Neo4Jay from 'neo4jay';
const Schema = Neo4Jay.Schema;
const ingredientSchema = new Schema({
name: {
required: true,
type: String
},
description: {
type: String
}
})
Public Methods
public relationsship(rel: function) source
Adds an instance relationship to documents constructed from Models compiled from this schema.
Params:
| Name | Type | Attribute | Description |
| rel | function | The relation type and options for the specific relationship, can only accept one relationship at the time. |
Example:
const Schema = Neo4Jay.Schema;
const Model = Neo4Jay.model;
const Relations = Neo4Jay.Relations;
ingredientSchema.relationsship(
Relations.hasMany('Nutrient', {
name: 'HAS_NUTRIENT',
schema: new Schema({
amount: {
type: Number,
required: true
}
})
})
)
const Schema = Neo4Jay.Schema;
const Model = Neo4Jay.model;
const Relations = Neo4Jay.Relations;
ingredientSchema.relationsship(
Relations.belongsToOne('IngredientType', {
name: 'HAS_INGREDIENT'
})
)