EntityProvider
Summary
Defines a provider holding a single type of resources.
An entity provider manages a single type of resources. These resources are stored into the given storage / location. Each entity must have an identification number held in the "id" property. An entity may also have a "locked" property to make it immutable.
Constructor
Methods
add
Syntax
add
-
entities -
[callback]
Summary
Adds entities.
get
Syntax
get
-
[filter] -
[fields] -
[limit] -
[page] -
[sort] -
callback
Summary
Fetches entities.
Parameters:
-
[filter]ResourceFilter optionalRules to filter entities
-
[fields]Object optionalFields to be included or excluded from the response, by default all fields are returned. Only "exclude" or "include" can be specified, not both
-
[limit]Number optionalA limit number of entities to retrieve (10 by default)
-
[page]Number optionalThe page number started at 0 for the first page
-
[sort]Object optionalThe list of fields to sort by with the field name as key and the sort order as value (e.g. {field1: 'asc', field2: 'desc'})
-
callbackFunctionThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Array The list of retrieved entities
- Object Pagination information
- Number limit The specified limit
- Number page The actual page
- Number pages The total number of pages
- Number size The total number of entities
getOne
Syntax
getOne
-
id -
[fields] -
callback
Summary
Fetches an entity by its id.
Parameters:
-
idStringThe entity id
-
[fields]Object optionalFields to be included or excluded from the response, by default all fields are returned. Only "exclude" or "include" can be specified, not both
-
callbackFunctionThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Object The entity
remove
Syntax
remove
-
[filter] -
[callback]
Summary
Removes entities.
Parameters:
-
[filter]ResourceFilter optionalRules to filter entities to remove
-
[callback]Function optionalThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number The number of removed entities
removeField
Syntax
removeField
-
field -
[filter] -
[callback]
Summary
Removes a field from entities.
Parameters:
-
fieldStringThe field to remove from entities
-
[filter]ResourceFilter optionalRules to filter entities to update
-
[callback]Function optionalThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number The number of updated entities
update
Syntax
update
-
[filter] -
data -
[callback]
Summary
Updates entities.
Parameters:
-
[filter]ResourceFilter optionalRules to filter entities to update
-
dataObjectThe modifications to perform
-
[callback]Function optionalThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number The number of updated entities