SchemaType Class
Description
The basic schema type constructor.
This is an abstract class. Every schema type should inherit this class. For example:
var SchemaCustom = function(options){ SchemaType.call(this, options);};SchemaCustom.__proto__ = SchemaType;SchemaCustom.prototype.__proto__ = SchemaType.prototype;Query operators
To add a query operator, adds a method whose name started with q$. For example:
SchemaCustom.q$foo = function(data, value){ // ...};The data parameter is the data in the database; the value parameter is the value passed to the query operator.
The return value should be a boolean indicating whether the data passed the test.
Update operators
To add a update operator, adds a method whose name started with u$. For example:
SchemaCustom.u$bar = function(data, value){ // ...};The data parameter is the data in the database; the value parameter is the value passed to the update operator.
The return value will replace the original data.
Constructor
SchemaType
([options])The basic schema type constructor.
This is an abstract class. Every schema type should inherit this class. For example:
var SchemaCustom = function(options){ SchemaType.call(this, options);};SchemaCustom.__proto__ = SchemaType;SchemaCustom.prototype.__proto__ = SchemaType.prototype;Query operators
To add a query operator, adds a method whose name started with q$. For example:
SchemaCustom.q$foo = function(data, value){ // ...};The data parameter is the data in the database; the value parameter is the value passed to the query operator.
The return value should be a boolean indicating whether the data passed the test.
Update operators
To add a update operator, adds a method whose name started with u$. For example:
SchemaCustom.u$bar = function(data, value){ // ...};The data parameter is the data in the database; the value parameter is the value passed to the update operator.
The return value will replace the original data.
Parameters
- options Object optional
Methods
cast
(value) AnyCasts a value.
Parameters
- value Any
Returns
- Any
checkRequired
(value) AnyValidates a value.
Parameters
- value Any
Returns
- Any
q$exists
(data, value) BooleanChecks whether the field exists.
q$exists is also aliased as q$exist.
Parameters
- data Any
- value Any
Returns
q$gte
(data, value) BooleanChecks whether data is greater than or equal to value.
q$gte is also aliased as q$min.
Parameters
- data Any
- value Any
Returns
q$lte
(data, value) BooleanChecks whether data is less than or equal to value.
q$lte is also aliased as q$max.
Parameters
- data Any
- value Any
Returns
q$ne
(data, value) BooleanChecks whether data is equal to value. If not, return true.
Parameters
- data Any
- value Any
Returns
save
(value) AnyTransforms a value into JSON.
Parameters
- value Any
Returns
- Any
Properties
default
The default value of the field.
required
Determines whether the field is required.