new Schema(definition)
js-data's Schema class.
import {Schema} from 'js-data'
Name | Type | Description |
---|---|---|
definition |
Object | Schema definition according to json-schema.org |
Extends
This class extends the Component class.Members
-
<static> typeGroupValidators
-
TODO
-
<static> types
-
TODO
-
<static> validationKeywords
-
TODO
-
_listeners
-
Event listeners attached to this Component. Do not modify. Use Component#on and Component#off instead.
DetailsType Since Source Object 3.0.0 Component.js, line 7 - Inherited From:
Methods
-
<static> validate(value, schema, opts)
-
TODO
Method parameters:Name Type Argument Description value
* TODO
schema
Object <optional>
TODO
opts
Object <optional>
Configuration options.
-
dbg(args)
-
Log the provided values at the "debug" level.
Method parameters:Name Type Argument Description args
* <optional>
<repeatable>
Values to log.
DetailsSince Source 3.0.0 Component.js, line 32 - Inherited From:
-
emit(event, args)
-
Trigger an event on this Component.
Method parameters:Name Type Argument Description event
String Name of event to emit.
args
* <optional>
<repeatable>
Arguments to pass to any listeners.
DetailsSince Source 3.0.0 Component.js, line 98 - Inherited From:
Examplescollection.on('foo', (msg) => { console.log(msg) // "bar" }) collection.emit('foo', 'bar')
store.on('foo', (msg, val1, val2) => { console.log(msg, val1, val2) // "bar" "beep" "boop" }) store.emit('foo', 'bar', 'beep', 'boop')
-
log(level, args)
-
Log the provided values. By default sends values to
console[level]
.Method parameters:Name Type Argument Description level
String Log level
args
* <optional>
<repeatable>
Values to log.
DetailsSince Source 3.0.0 Component.js, line 39 - Inherited From:
-
off(event, listener)
-
Remove an event listener from this Component. If no listener is provided, then all listeners for the specified event will be removed. If no event is specified then all listeners for all events will be removed.
Method parameters:Name Type Argument Description event
String <optional>
Name of event to unsubsribe to.
listener
Function <optional>
Listener to remove.
DetailsSince Source 3.0.0 Component.js, line 79 - Inherited From:
Examplescollection.off('add', handler)
record.off('change')
store.off()
-
on(event, listener, ctx)
-
Register a new event listener on this Component.
Method parameters:Name Type Argument Description event
String Name of event to subsribe to.
listener
Function Listener function to handle the event.
ctx
* <optional>
Optional content in which to invoke the listener.
DetailsSince Source 3.0.0 Component.js, line 49 - Inherited From:
Examplesstore.on('afterCreate', (mapperName, props, opts, result) => { console.log(mapperName) // "post" console.log(props.id) // undefined console.log(result.id) // 1234 }) store.create('post', { title: 'Modeling your data' }).then((post) => { console.log(post.id) // 1234 })
collection.on('add', (records) => { console.log(records) // [...] })
post.on('change', (record, changes) => { console.log(changes) // { changed: { title: 'Modeling your data' } } }) post.title = 'Modeling your data'
-
validate(value, opts)
-
Validate the provided value against this schema.
Method parameters:Name Type Argument Description value
* Value to validate.
opts
Object <optional>
Configuration options.
Return value:Type Description Array | undefined Array of errors or
undefined
if valid. -
validate(target)
-
This adds ES5 getters/setters to the target based on the "properties" in this Schema, which makes possible change tracking and validation on property assignment.
Method parameters:Name Type Description target
Object The prototype to which to apply this schema.