Repository
public class |source

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

Member Summary

Public Members
public
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

addItem(data: Object, collection: String, callback: Function)

Adds an item to a collection

public

clearCollection(name: String, options: Object)

Clears a collection

public

Close the socket connection

public

getID(): *

Get the socket id

public

getItem(id: Number, collection: String, callback: Function)

Get"s an item from a collection by it"s ID

public

getItemID(item: Object): *

Get"s an item"s ID

public

Lists available collections

public

open(url: String)

Open the socket connection

public

queryCollectionItems(name: String, query: Object, callback: Function)

Runs a query on a collection

public

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 Constructors

public constructor(params: Object) source

Params:

NameTypeAttributeDescription
paramsObject

Parameters object, given by the constructor.

params.urlString

The URL of the server on which the MobilizingServer instance is running

params.autoConnectBoolean
  • optional
  • default: true

Whether the connection should be automatically opened

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:

NameTypeAttributeDescription
nameString

The collection"s name

optionsObject

Options used for the creation; see https://rawgit.com/techfort/LokiJS/master/jsdoc/Loki.html#addCollection

callbackFunction

The callback to invoke with the new collection name

public addItem(data: Object, collection: String, callback: Function) source

Adds an item to a collection

Params:

NameTypeAttributeDescription
dataObject

The data used to create the new item

collectionString
  • optional

The collection"s name to which the item should belong, the default collection is used if undefined

callbackFunction
  • optional

The callback to invoke with the added item

public clearCollection(name: String, options: Object) source

Clears a collection

Params:

NameTypeAttributeDescription
nameString

The collection"s name

optionsObject
  • optional

Options to configure the clear behavior

options.removeIndicesBoolean
  • optional

Whether to also remove indices from the collection

public close() source

Close the socket connection

public getID(): * source

Get the socket id

Return:

*

public getItem(id: Number, collection: String, callback: Function) source

Get"s an item from a collection by it"s ID

Params:

NameTypeAttributeDescription
idNumber

The item"s id

collectionString
  • optional

The collection"s name to which the item belongs, the default collection is used if undefined

callbackFunction
  • optional

The callback to invoke with the item

public getItemID(item: Object): * source

Get"s an item"s ID

Params:

NameTypeAttributeDescription
itemObject

The item

Return:

*

public listCollections(callback: Function) source

Lists available collections

Params:

NameTypeAttributeDescription
callbackFunction

The callback to invoke with the list of collection names

public open(url: String) source

Open the socket connection

Params:

NameTypeAttributeDescription
urlString

URL of the Storage server instance

public queryCollectionItems(name: String, query: Object, callback: Function) source

Runs a query on a collection

Params:

NameTypeAttributeDescription
nameString

The collection"s name on which the query should be run, the default collection is used if undefined

queryObject

The options of the query to run

query.whereObject

The query"s where clause (see LokiJS:Resultset.find)

query.sortArray

Array of property names or subarray of [propertyname, isdesc] used to evaluate sort order, (see LokiJS:Resultset.compoundsort)

query.limitNumber

Limit the number of returned items (see LokiJS:Resultset.limit)

query.offsetNumber

An offset to skip a number of items in the result (see LokiJS:Resultset.offset)

query.countObject

Executes the query as a count query, only returning the number of results (see LokiJS:Resultset.count)

callbackFunction

The callback to invoke with the returned set

public removeCollection(name: String) source

Removes a collection

Params:

NameTypeAttributeDescription
nameString

The collection"s name

public removeCollectionItems(name: String, query: Object, callback: Function) source

Removes a collection"s items based on a query

Params:

NameTypeAttributeDescription
nameString

The collection"s name

queryObject

The options of the query to run

query.whereObject

The query"s where clause (see LokiJS:Resultset.find)

query.sortArray

Array of property names or subarray of [propertyname, isdesc] used to evaluate sort order, (see LokiJS:Resultset.compoundsort)

query.limitNumber

Limit the number of returned items (see LokiJS:Resultset.limit)

query.offsetNumber

An offset to skip a number of items in the result (see LokiJS:Resultset.offset)

callbackFunction
  • optional

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

Params:

NameTypeAttributeDescription
itemObject

The item to remove

collectionString
  • optional

The collection"s name to which the item belongs, the default collection is used if undefined

callbackFunction
  • optional

The callback to invoke with the removed item

public updateCollectionItems(name: String, data: Object, query: Object, callback: Function) source

Updates a collection"s items based on a query

Params:

NameTypeAttributeDescription
nameString

The collection"s name

dataObject

The data to update the items with

queryObject

The options of the query to run

query.whereObject

The query"s where clause (see LokiJS:Resultset.find)

query.sortArray

Array of property names or subarray of [propertyname, isdesc] used to evaluate sort order, (see LokiJS:Resultset.compoundsort)

query.limitNumber

Limit the number of returned items (see LokiJS:Resultset.limit)

query.offsetNumber

An offset to skip a number of items in the result (see LokiJS:Resultset.offset)

callbackFunction
  • optional

The callback to invoke with the count of updated items

public updateItem(id: Number, data: Object, collection: String, callback: Function) source

Updates an item in a collection

Params:

NameTypeAttributeDescription
idNumber

The item"s id

dataObject

The data to update the item with

collectionString
  • optional

The collection"s name to which the item belongs, the default collection is used if undefined

callbackFunction
  • optional

The callback to invoke with the updated item