Storage
Summary
Defines base storage for all storages.
A storage is capable of performing CRUD (Create Read Update Delete) operations on resources.
This should not be used directly, use one of its subclasses instead.
Constructor
Storage
Syntax
Storage
-
configuration
Summary
Parameters:
-
configurationObjectStorage configuration which depends on the Storage type
Methods
add
Syntax
add
-
location -
resources -
[callback]
Summary
Adds resources to the storage.
get
Syntax
get
-
location -
[filter] -
[fields] -
[limit] -
[page] -
[sort] -
callback
Summary
Fetches resources from the storage.
Parameters:
-
locationStringThe storage location where to search for resources
-
[filter]ResourceFilter optionalRules to filter resources
-
[fields]Object optionalExpected resource fields 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 resources 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 resources
- 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 resources
getOne
Syntax
getOne
-
location -
[filter] -
[fields] -
callback
Summary
Fetches a single resource from the storage.
Parameters:
-
locationStringThe storage location where to search for the resource
-
[filter]ResourceFilter optionalRules to filter resources
-
[fields]Object optionalExpected resource fields 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 resource
remove
Syntax
remove
-
location -
filter -
[callback]
Summary
Removes resources from the storage.
Parameters:
-
locationStringThe storage location where to find the resources to remove
-
filterResourceFilterRules to filter resources 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 resources
removeField
Syntax
removeField
-
location -
field -
[filter] -
[callback]
Summary
Removes a field from resources of a storage location.
Parameters:
-
locationStringThe storage location where to find the resources
-
fieldStringThe field to remove from resources
-
[filter]ResourceFilter optionalRules to filter resources 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 resources
update
Syntax
update
-
location -
filter -
data -
[callback]
Summary
Updates resources in the storage.
Parameters:
-
locationStringThe storage location where to find the resources to update
-
filterResourceFilterRules to filter resources 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 resources