Constructor
new Schema(definition)
Instantiates the schema and builds the schema object from the provided definition.
Name | Type | Description |
---|---|---|
definition |
object | the schema definition |
- Source:
Members
definition :object
The original schema definition.
- object
- Source:
schema :object
The built schema object.
- object
- Source:
types :object
Schema types supported by this Schema class. Provides a mapping from reference name => Type class.
- object
- Source:
Methods
build_schema(defs) → {object}
Recursively build a schema object from the provided definition.
Name | Type | Description |
---|---|---|
defs |
object | the schema definition |
- Source:
- the schema object
- Type
- object
cast_to_schema(object, levelopt) → {object}
Cast the provided object to the specified schema. Particularly, this function is used externally to cast objects to this schema, recursively.
After this cast, the resulting object is safe to persist, at least for what this library guarantees.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
object |
object | object to cast |
||
level |
object |
<optional> |
false | the current level of the schema object (usually leave this blank) |
- Source:
- the casted object
- Type
- object
parse_default(default_value) → {function}
Create a function that returns the specified default value. If default_value is a function, it will be called. Otherwise, this will return a function that evaluates to default_value.
Name | Type | Description |
---|---|---|
default_value |
function | * |
- Source:
- Type
- function
parse_type(type) → {module:flitter-orm/src/schema/Type~Type}
Parse the schema type from the specified type identifier.
Name | Type | Description |
---|---|---|
type |
Date | String | Number | Boolean | ObjectId | Array | Object |
- Source: