API Documentation

for 0.0.1
Show:

Storage Class

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

Constructor

Storage

(
  • params
)

Parameters:

  • params Object

    The parameters object

    • url String

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

    • [autoConnect=true] Boolean optional

      Whether the connection should be automatically opened

Example:

//TODO

Methods

addCollection

(
  • name
  • options
  • callback
)

Adds a new collection

Parameters:

addItem

(
  • data
  • [collection]
  • [callback]
)

Adds an item to a collection

Parameters:

  • data Object

    The data used to create the new item

  • [collection] String optional

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

  • [callback] Function optional

    The callback to invoke with the added item

clearCollection

(
  • name
  • [options]
)

Clears a collection

Parameters:

  • name String

    The collection's name

  • [options] Object optional

    Options to configure the clear behavior

    • [removeIndices] Boolean optional

      Whether to also remove indices from the collection

close

()

Close the socket connection

getID

()

Get the socket id

getItem

(
  • id
  • [collection]
  • [callback]
)

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

Parameters:

  • id Number

    The item's id

  • [collection] String optional

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

  • [callback] Function optional

    The callback to invoke with the item

getItemID

(
  • item
)

Get's an item's ID

Parameters:

  • item Object

    The item

listCollections

(
  • callback
)

Lists available collections

Parameters:

  • callback Function

    The callback to invoke with the list of collection names

open

(
  • url
)

Open the socket connection

Parameters:

  • url String

    URL of the Storage server instance

queryCollectionItems

(
  • name
  • query
  • callback
)

Runs a query on a collection

Parameters:

  • 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

    • where Object

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

    • sort Array

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

    • limit Number

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

    • offset Number

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

    • 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

removeCollection

(
  • name
)

Removes a collection

Parameters:

  • name String

    The collection's name

removeCollectionItems

(
  • name
  • query
  • [callback]
)

Removes a collection's items based on a query

Parameters:

  • name String

    The collection's name

  • query Object

    The options of the query to run

    • where Object

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

    • sort Array

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

    • limit Number

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

    • offset Number

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

  • [callback] Function optional

    The callback to invoke with the count of removed items

removeItem

(
  • item
  • [collection]
  • [callback]
)

Removes an item from a collection

Parameters:

  • item Object

    The item to remove

  • [collection] String optional

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

  • [callback] Function optional

    The callback to invoke with the removed item

updateCollectionItems

(
  • name
  • data
  • query
  • [callback]
)

Updates a collection's items based on a query

Parameters:

  • name String

    The collection's name

  • data Object

    The data to update the items with

  • query Object

    The options of the query to run

    • where Object

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

    • sort Array

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

    • limit Number

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

    • offset Number

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

  • [callback] Function optional

    The callback to invoke with the count of updated items

updateItem

(
  • id
  • data
  • [collection]
  • [callback]
)

Updates an item in a collection

Parameters:

  • id Number

    The item's id

  • data Object

    The data to update the item with

  • [collection] String optional

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

  • [callback] Function optional

    The callback to invoke with the updated item

Events

connect

Fired when the client successfully connects to the server

connect_timeout

Fired when a connection times out

disconnect

Fired when the client disconnects from the server

error

Fired when a connection error occurs