Module: Schema

Class represents the Schema definition for Model and Source This is basically just a big config object, used to instantiate a Model and Source. Usage: - const schema = new Schema({ name: 'Users', model: {}, repository: {}, }); To define a virtual property: { name: 'virtual', depends: 'bar', parse: function(rawValue) { // NOTE: Use standard function notation, so this === the Property object // const originalData = this._entity._originalData, // This gives access to all original data that was supplied to Entity // parsedData = this._entity.data; // This gives access to all other parsed Properties return 'This property is ' + this.name + ' and the value of bar is ' + this._entity.bar; } },

new (require("Schema"))(config)

Parameters:
Name Type Description
config object Settings for this schema. Each setting overrides its default value
Source:
Schema/Schema.js

Members


<inner> name :string

Could be anything, but OneHat's convention is to use the model name pluralized and camel-cased (e.g. 'Users')
Type:
  • string
Source:
Schema/Schema.js

<inner> model :object

Config for Model
Type:
  • object
Source:
Schema/Schema.js

<inner> idProperty :string

name of id Property (e.g. 'users__id')
Type:
  • string
Source:
Schema/Schema.js

<inner> displayProperty :string

name of display Property (e.g. 'users__username')
Type:
  • string
Source:
Schema/Schema.js

<inner> propertyDefinitions :array

Array of Property definition objects
Type:
  • array
Source:
Schema/Schema.js

<inner> sorters :Array.<object>

Array of sorter definitions. Each definition is an object with two keys: - *name* - Name of Property to sort by. - *direction* - 'ASC'|'DESC'
Type:
  • Array.<object>
Source:
Schema/Schema.js

<inner> associations :object

List of associated Models
Type:
  • object
Source:
Schema/Schema.js

<inner> hasOne :array

Array of names of associated Models
Type:
  • array
Source:
Schema/Schema.js

<inner> hasMany :array

Array of names of associated Models
Type:
  • array
Source:
Schema/Schema.js

<inner> belongsTo :array

Array of names of associated Models
Type:
  • array
Source:
Schema/Schema.js

<inner> belongsToMany :array

Array of names of associated Models
Type:
  • array
Source:
Schema/Schema.js

<inner> repository :object|string

Config for Repository
Type:
  • object | string
Source:
Schema/Schema.js

destroy

Destroy this object. - Removes child objects
Source:
Schema/Schema.js

Module: Schema

Class represents the Schema definition for Model and Source This is basically just a big config object, used to instantiate a Model and Source. Usage: - const schema = new Schema({ name: 'Users', model: {}, repository: {}, }); To define a virtual property: { name: 'virtual', depends: 'bar', parse: function(rawValue) { // NOTE: Use standard function notation, so this === the Property object // const originalData = this._entity._originalData, // This gives access to all original data that was supplied to Entity // parsedData = this._entity.data; // This gives access to all other parsed Properties return 'This property is ' + this.name + ' and the value of bar is ' + this._entity.bar; } },

new (require("Schema"))(config)

Parameters:
Name Type Description
config object Settings for this schema. Each setting overrides its default value
Source:
Schema/Schema.js

Members


<inner> name :string

Could be anything, but OneHat's convention is to use the model name pluralized and camel-cased (e.g. 'Users')
Type:
  • string
Source:
Schema/Schema.js

<inner> model :object

Config for Model
Type:
  • object
Source:
Schema/Schema.js

<inner> idProperty :string

name of id Property (e.g. 'users__id')
Type:
  • string
Source:
Schema/Schema.js

<inner> displayProperty :string

name of display Property (e.g. 'users__username')
Type:
  • string
Source:
Schema/Schema.js

<inner> propertyDefinitions :array

Array of Property definition objects
Type:
  • array
Source:
Schema/Schema.js

<inner> sorters :Array.<object>

Array of sorter definitions. Each definition is an object with two keys: - *name* - Name of Property to sort by. - *direction* - 'ASC'|'DESC'
Type:
  • Array.<object>
Source:
Schema/Schema.js

<inner> associations :object

List of associated Models
Type:
  • object
Source:
Schema/Schema.js

<inner> hasOne :array

Array of names of associated Models
Type:
  • array
Source:
Schema/Schema.js

<inner> hasMany :array

Array of names of associated Models
Type:
  • array
Source:
Schema/Schema.js

<inner> belongsTo :array

Array of names of associated Models
Type:
  • array
Source:
Schema/Schema.js

<inner> belongsToMany :array

Array of names of associated Models
Type:
  • array
Source:
Schema/Schema.js

<inner> repository :object|string

Config for Repository
Type:
  • object | string
Source:
Schema/Schema.js

destroy

Destroy this object. - Removes child objects
Source:
Schema/Schema.js

Module: Schema

Class represents the Schema definition for Model and Source This is basically just a big config object, used to instantiate a Model and Source. Usage: - const schema = new Schema({ name: 'Users', model: {}, repository: {}, }); To define a virtual property: { name: 'virtual', depends: 'bar', parse: function(rawValue) { // NOTE: Use standard function notation, so this === the Property object // const originalData = this._entity._originalData, // This gives access to all original data that was supplied to Entity // parsedData = this._entity.data; // This gives access to all other parsed Properties return 'This property is ' + this.name + ' and the value of bar is ' + this._entity.bar; } },

new (require("Schema"))(config)

Parameters:
Name Type Description
config object Settings for this schema. Each setting overrides its default value
Source:
Schema/Schema.js

Members


<inner> name :string

Could be anything, but OneHat's convention is to use the model name pluralized and camel-cased (e.g. 'Users')
Type:
  • string
Source:
Schema/Schema.js

<inner> model :object

Config for Model
Type:
  • object
Source:
Schema/Schema.js

<inner> idProperty :string

name of id Property (e.g. 'users__id')
Type:
  • string
Source:
Schema/Schema.js

<inner> displayProperty :string

name of display Property (e.g. 'users__username')
Type:
  • string
Source:
Schema/Schema.js

<inner> propertyDefinitions :array

Array of Property definition objects
Type:
  • array
Source:
Schema/Schema.js

<inner> sorters :Array.<object>

Array of sorter definitions. Each definition is an object with two keys: - *name* - Name of Property to sort by. - *direction* - 'ASC'|'DESC'
Type:
  • Array.<object>
Source:
Schema/Schema.js

<inner> associations :object

List of associated Models
Type:
  • object
Source:
Schema/Schema.js

<inner> hasOne :array

Array of names of associated Models
Type:
  • array
Source:
Schema/Schema.js

<inner> hasMany :array

Array of names of associated Models
Type:
  • array
Source:
Schema/Schema.js

<inner> belongsTo :array

Array of names of associated Models
Type:
  • array
Source:
Schema/Schema.js

<inner> belongsToMany :array

Array of names of associated Models
Type:
  • array
Source:
Schema/Schema.js

<inner> repository :object|string

Config for Repository
Type:
  • object | string
Source:
Schema/Schema.js

destroy

Destroy this object. - Removes child objects
Source:
Schema/Schema.js