Constructor
new Storage(configuration)
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.
Parameters:
Name | Type | Description |
---|---|---|
configuration |
Object | Storage configuration which depends on the Storage type |
- Source:
Throws:
-
If configuration is missing
- Type
- TypeError
Members
(readonly) configuration :Object
The storage configuration.
Type:
- Object
- Source:
Methods
add(location, resources, callbackopt)
Adds resources to the storage.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
location |
String | The storage location where the resource will be added |
|
resources |
Array | The list of resources to store |
|
callback |
module:storages/Storage~Storage~addCallback |
<optional> |
The function to call when it's done |
- Source:
get(location, filteropt, fieldsopt, limitopt, pageopt, sortopt, callback)
Fetches resources from the storage.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
location |
String | The storage location where to search for resources |
|||||||||||||
filter |
module:storages/ResourceFilter~ResourceFilter |
<optional> |
Rules to filter resources |
||||||||||||
fields |
Object |
<optional> |
Expected 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 Properties
|
||||||||||||
limit |
Number |
<optional> |
A limit number of resources to retrieve (10 by default) |
||||||||||||
page |
Number |
<optional> |
The page number started at 0 for the first page |
||||||||||||
sort |
Object |
<optional> |
The list of fields to sort by with the field name as key and the sort order as value (e.g. {field1: 'asc', field2: 'desc'}) |
||||||||||||
callback |
module:storages/Storage~Storage~getCallback | The function to call when it's done |
- Source:
getOne(location, filteropt, fieldsopt, callback)
Fetches a single resource from the storage.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
location |
String | The storage location where to search for the resource |
|||||||||||||
filter |
module:storages/ResourceFilter~ResourceFilter |
<optional> |
Rules to filter resources |
||||||||||||
fields |
Object |
<optional> |
Expected 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 Properties
|
||||||||||||
callback |
module:storages/Storage~Storage~getOneCallback | The function to call when it's done |
- Source:
remove(location, filter, callbackopt)
Removes resources from the storage.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
location |
String | The storage location where to find the resources to remove |
|
filter |
module:storages/ResourceFilter~ResourceFilter | Rules to filter resources to remove |
|
callback |
module:storages/Storage~Storage~removeCallback |
<optional> |
The function to call when it's done |
- Source:
removeField(location, field, filteropt, callbackopt)
Removes a field from resources of a storage location.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
location |
String | The storage location where to find the resources |
|
field |
String | The field to remove from resources |
|
filter |
module:storages/ResourceFilter~ResourceFilter |
<optional> |
Rules to filter resources to update |
callback |
module:storages/Storage~Storage~removeFieldCallback |
<optional> |
The function to call when it's done |
- Source:
updateOne(location, filter, data, callbackopt)
Updates a resource in the storage.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
location |
String | The storage location where to find the resource to update |
|
filter |
module:storages/ResourceFilter~ResourceFilter | Rules to filter the resource to update |
|
data |
Object | The modifications to perform |
|
callback |
module:storages/Storage~Storage~updateOneCallback |
<optional> |
The function to call when it's done |
- Source:
Type Definitions
addCallback(error, total, resources)
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | null | The error if an error occurred, null otherwise |
total |
Number | Undefined | The total amount of resources inserted |
resources |
Array | Undefined | The list of inserted resources |
- Source:
getCallback(error, resources, pagination)
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
error |
Error | null | The error if an error occurred, null otherwise |
|||||||||||||||
resources |
Array | Undefined | The list of retrieved resources |
|||||||||||||||
pagination |
Object | Undefined | Pagination information Properties
|
- Source:
getOneCallback(error, resource)
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | null | The error if an error occurred, null otherwise |
resource |
Object | Undefined | The resource |
- Source:
removeCallback(error, The)
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | null | The error if an error occurred, null otherwise |
The |
Number | Undefined | number of removed resources |
- Source:
removeFieldCallback(error, The)
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | null | The error if an error occurred, null otherwise |
The |
Number | Undefined | number of updated resources |
- Source:
updateOneCallback(error, 1)
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | null | The error if an error occurred, null otherwise |
1 |
Number | Undefined | if everything went fine |
- Source: