Syntax
Description
Defines what data is sent to the client (entity.getData is called) and how changes are applied when the data is received back from the client (entity.setData is called).
Schema
Name | Value | Description |
---|---|---|
$ | options | entity schema options to change. See defaults and examples for more information. |
property | propertySchema | Corresponding property schema changes. |
Options
Option | Value | Description |
---|---|---|
get | true or false | Specifies whether the property should be sent to the client *) |
function(property), this:entity | Return undefined or a value to send to the client *) | |
set | true or false | Specifies whether the property should be updated when data is received from the client **) |
function(property, data), this:entity | Apply the data to entity.property or return undefined or new data to have the applied to object.property **) | |
nested | true or false | Overrides get and set for nested objects (see "Default schema" below for an example). |
Certain functions can extend and/or modify the options above for the corresponding properties, for examples see addReference or addCollection.
Default schema
entity.$schema({
fields: {$: {get: true, set: true}},
references: {$: {get: true, set: true, nested: false}},
collections: {$: {get: true, nested: false}}
});
Fields are sent to the client and the client changes are applied when the data is received.
Referenced items are sent to the client. Client can change which item is referenced, but cannot create, modify or delete the referenced items.
Collection items are sent to the client. Client cannot create, add, update or delete the collection items.
Further references and collections are not sent and corresponding changes are not accepted.
Examples
Given a job:
Overriding:
For type: