The script object api.resources is used for saving, updating, deleting,
retrieving and searching for objects in their respective stores or proxies.
api.resources.get
Returns the specified resource object based on its $id value or null if
the object is not found.
$id
The id of the resource being retrieved.
cls optional
The resource class constructor object OR the full class name of the resource class prefixed with its module name. This is used to locate the correct store. If the resourceId is known to exist in the internal store, this does not need to be provided. If it is provided it is also used to validate the resource type.
The resource object associated with the $id or null if it is not found.
api.resources.search
Performs a search for the resource objects of the type specified by the provided class using the query string provided. Search is based on Elasticsearch’s query string syntax.
cls
The resource class constructor object OR the full class name of the resource class prefixed with its module name. This can also be a super class or abstract class. All subclass objects will be returned if this class is a super class.
term
The Elasticsearch query string search term. See Elasticsearch query string search format for more information.
pageSize optional
The page size for the response. The object is returned is an infinitely scrolling array and paging occurs automatically as a result. Therefore there is no need to keep querying for new pages. The page size is 10 by default.
orderBy optional
A CSV of property names used to define the order of the objects in the result.
Each entry in the CSV has the format: <property-name>[ <direction>]. <property-name>
is can be any property in the resource object including nested properties,
but it cannot be a property in a nested resource object. <direction> is
optional and if supplied can be one of ASC (ascending) or DESC
(descending). The order is based off Elasticsearch’s best match scoring by default.
The response to this service is an array object that has uses internally an infinite scroll. If the array is used in a for loop or if an indexed item is retrieved that is not in the current page, the array will retrieve the appropriate page automatically. The developer does not need to write paging code.
api.resources.delete
Deletes the specified resource object.
object
The resource object being deleted.
flush optional
If supplied and if it this is true, the delete will occur immediately and independently of the main outer transaction. By default the delete will be run once the entire transaction is committed. If the main transaction is rolled back, this delete will also be rolled back unless flush is true.
Explicitly saves the resource object. By default, if an object is modified and the initiating request is an UPDATE or CREATE, the object will be saved automatically.
object
The resource object being saved. This object will be updated internally with
relevant rule updates and an $id value if it is a new object. Consequently
this is both an input object and an output object.
flush optional
If supplied and if it this is true, the save will occur immediately and independently of the main outer transaction. By default the save will be run once the entire transaction is committed. If the main transaction is rolled back, this save will also be rolled back unless flush is true.