New in package 166
Syntax
Database.addCollection( entity, 'property', query, options );
Description
Adds an entity.property which represents a collection of items defined by the query.
Parameters
Parameter | Description |
---|---|
property | Name of the property to define. |
query | A repository, result of repository.where(...) etc. |
Options
Default options
{ get: true, create: false, add: false, update: false, delete: false, order: null }
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 *) | |
create | true or false | Specifies whether new items can be created from the client **) |
function(itemData) | Can return true, false, null, undefined or a new item created from the itemData. | |
add | true or false | Specifies whether items can be added to the collection from the client **) |
function(item) | Return true to have the item added to the collection from the client **) | |
update | true or false | specifies whether changes should be applied to the items from the client **) |
function(item, itemData) | can apply the changes to the item. | |
delete | true or false | Specifies whether items can be deleted from the collection from the client **) |
function(item) | Can delete the specified item. Return a truthy value to have the item deleted. | |
order | field name or null | Specifies the name of an integer field where to write the "line number" according to the order specified in the data received from the client **) |
*) i.e. when entity.getData is called
**) i.e. when entity.setData is called
Example
Update 'Line_Number' field according to the order specified in the data received from the client:
"Disassociate" items with a job on delete:
Delete the referenced items from the database on delete:
Read-only list of jobs on a dashboard:
A list of jobs on a dashboard, where jobs can be added and removed from the list, but not updated: