import Storage from '@mobilizing/library/js/Mobilizing/net/Storage.js'
Storage
Storage is a client for the Storage server It allows remote persistant storage A runing instance of the Storage server is required to make this work
Example:
//@TODO
Constructor Summary
Public Constructor | ||
public | constructor(params: Object) |
Member Summary
Public Members | ||
public | autoConnect: * | |
public | events: * | |
public | id: * | |
public | socket: * | |
public | url: * |
Method Summary
Public Methods | ||
public | addCollection(name: String, options: Object, callback: Function) Adds a new collection | |
public | Adds an item to a collection | |
public | clearCollection(name: String, options: Object) Clears a collection | |
public | close() Close the socket connection | |
public | getID(): * Get the socket id | |
public | Get"s an item from a collection by it"s ID | |
public | Get"s an item"s ID | |
public | listCollections(callback: Function) Lists available collections | |
public | Open the socket connection | |
public | queryCollectionItems(name: String, query: Object, callback: Function) Runs a query on a collection | |
public | removeCollection(name: String) Removes a collection | |
public | removeCollectionItems(name: String, query: Object, callback: Function) Removes a collection"s items based on a query | |
public | removeItem(item: Object, collection: String, callback: Function) Removes an item from a collection | |
public | updateCollectionItems(name: String, data: Object, query: Object, callback: Function) Updates a collection"s items based on a query | |
public | updateItem(id: Number, data: Object, collection: String, callback: Function) Updates an item in a collection |
Public Members
public autoConnect: * source
public events: * source
public id: * source
public socket: * source
public url: * source
Public Methods
public addCollection(name: String, options: Object, callback: Function) source
Adds a new collection
Params:
Name | Type | Attribute | Description |
name | String | The collection"s name | |
options | Object | Options used for the creation; see https://rawgit.com/techfort/LokiJS/master/jsdoc/Loki.html#addCollection | |
callback | Function | The callback to invoke with the new collection name |
public addItem(data: Object, collection: String, callback: Function) source
Adds an item to a collection
public close() source
Close the socket connection
public getItem(id: Number, collection: String, callback: Function) source
Get"s an item from a collection by it"s ID
public getItemID(item: Object): * source
Get"s an item"s ID
Params:
Name | Type | Attribute | Description |
item | Object | The item |
Return:
* |
public listCollections(callback: Function) source
Lists available collections
Params:
Name | Type | Attribute | Description |
callback | Function | The callback to invoke with the list of collection names |
public open(url: String) source
Open the socket connection
Params:
Name | Type | Attribute | Description |
url | String | URL of the Storage server instance |
public queryCollectionItems(name: String, query: Object, callback: Function) source
Runs a query on a collection
Params:
Name | Type | Attribute | Description |
name | String | The collection"s name on which the query should be run, the default collection is used if undefined | |
query | Object | The options of the query to run | |
query.where | Object | The query"s where clause (see LokiJS:Resultset.find) | |
query.sort | Array | Array of property names or subarray of [propertyname, isdesc] used to evaluate sort order, (see LokiJS:Resultset.compoundsort) | |
query.limit | Number | Limit the number of returned items (see LokiJS:Resultset.limit) | |
query.offset | Number | An offset to skip a number of items in the result (see LokiJS:Resultset.offset) | |
query.count | Object | Executes the query as a count query, only returning the number of results (see LokiJS:Resultset.count) | |
callback | Function | The callback to invoke with the returned set |
public removeCollection(name: String) source
Removes a collection
Params:
Name | Type | Attribute | Description |
name | String | The collection"s name |
public removeCollectionItems(name: String, query: Object, callback: Function) source
Removes a collection"s items based on a query
Params:
Name | Type | Attribute | Description |
name | String | The collection"s name | |
query | Object | The options of the query to run | |
query.where | Object | The query"s where clause (see LokiJS:Resultset.find) | |
query.sort | Array | Array of property names or subarray of [propertyname, isdesc] used to evaluate sort order, (see LokiJS:Resultset.compoundsort) | |
query.limit | Number | Limit the number of returned items (see LokiJS:Resultset.limit) | |
query.offset | Number | An offset to skip a number of items in the result (see LokiJS:Resultset.offset) | |
callback | Function |
| The callback to invoke with the count of removed items |
public removeItem(item: Object, collection: String, callback: Function) source
Removes an item from a collection
public updateCollectionItems(name: String, data: Object, query: Object, callback: Function) source
Updates a collection"s items based on a query
Params:
Name | Type | Attribute | Description |
name | String | The collection"s name | |
data | Object | The data to update the items with | |
query | Object | The options of the query to run | |
query.where | Object | The query"s where clause (see LokiJS:Resultset.find) | |
query.sort | Array | Array of property names or subarray of [propertyname, isdesc] used to evaluate sort order, (see LokiJS:Resultset.compoundsort) | |
query.limit | Number | Limit the number of returned items (see LokiJS:Resultset.limit) | |
query.offset | Number | An offset to skip a number of items in the result (see LokiJS:Resultset.offset) | |
callback | Function |
| The callback to invoke with the count of updated items |