New in package 166
Syntax
Database.addReference( entity, 'property', repository, 'field', options );
Adds an entity.property which references a repository item defined by the entity.[$fields].field.
Parameters
Parameter | Description |
---|---|
property | Name of the property to define. |
repository | A repository, query or type name. |
field | Name of the field used to look up the referenced item. |
Options
Default options
{ get: true, set: true, create: false, update: false, delete: false }
Options description
Option | Value | Description |
---|---|---|
get | true or false | Specifies whether items should be sent to the client *) |
function(item) | Return true to have the item sent to the client *) | |
set | true or false | Specifies whether an item can be assigned to the entity.property from the client **) |
function(item) | Return true to have the item assigned to entity.property **) | |
create | true or false | Specifies whether new item can be created from the client *) |
function(itemData) | Can return true, false, null or a new item created from the itemData. | |
update | true or false | Specifies whether changes should be applied to the referenced item from the client **) |
function(item, itemData) | Can apply the changes to the item or modify itemData. Return true to have itemData applied to the item. | |
delete | true or false | Specifies whether the referenced item can be deleted from the client (by sending { $delete: true } ) **) |
function(item) | Can delete the specified item or return true or false. |
*) i.e. when entity.getData is called
**) i.e. when entity.setData is called