API Docs for: 1.0b
Show:

Driver Class

This is the skeleton Driver class. The class will be used as the base class for all the drivers implementation

Constructor

Driver

(
  • options
)

Defined in src/Driver.js:7

Parameters:

  • options Object
    • table String

      will be used as key identifier between db instances

    • [db_name] String optional

      can be used as an additional identifier to differentiate between instances

    • [db_size] Int optional

      can be used in cases where db allows setting size limit (not consistent)

    • [timeout=5000] Int optional

      how long to wait after a query has fired before timing out the request

Methods

addEvent

(
  • the
  • a
)
chainable

Adds an event

Parameters:

  • the String

    event type

  • a Function

    function to add

addEventOnce

(
  • the
  • a
)
chainable

Adds an event for one execution, then removes it

Parameters:

  • the String

    event type

  • a Function

    function to add

addEvents

(
  • literal
)
chainable

Helper to add multiple events at once

Parameters:

  • literal Object

    object of event types => callbacks

clear

(
  • [callback]
)
chainable async

Defined in src/Driver.js:78

Delete all the records from the storage


  clear(function callback(Error|null))
  

Parameters:

  • [callback] Function optional
    • A callback function that will be invoked after the clear.

clearTimeout

(
  • handle
)
protected

Defined in src/Driver.js:315

this method is used to clear the timeout counter of a request timeout

Parameters:

  • handle Object

    the timeout handle

destroy

() chainable

Defined in src/Driver.js:255

each

(
  • callback
)
chainable async

Defined in src/Driver.js:96

Run the callback method on all the storage items.


  each(function callback(Error|null, String key, String value)
  

Parameters:

  • callback Function
    • A callback function that will handle the results. The callback parameters are (key, value)

exists

(
  • key
  • callback
)
Boolean chainable async

Defined in src/Driver.js:115

Check to see if the given key already exist in the Storage


  exists(String key, function callback(Error|null, boolean)

Parameters:

  • key String
    • The key of the item we want to check if exits
  • callback Function
    • A callback function that will handle the results. The callback parameters are (key, value)

Returns:

Boolean: exists - true/false if the key exists or not

fireEvent

(
  • event
  • arguments
)
chainable

dispatches an event

Parameters:

  • event String

    type

  • arguments Mixed

    to pass with the event

fireLatchedEvent

(
  • the
  • arguments
)
chainable

Fires a latched event

Parameters:

  • the String

    event type

  • arguments Mixed

    to pass with the event

generateError

(
  • [type]
  • [msg]
  • [original_error]
)
Bucket.error protected

Defined in src/Driver.js:274

Generate new Bucket.error object and fires the error event

Parameters:

  • [type] String optional

    Bucket.error.TYPES constant.

  • [msg] String optional

    the error massage we want to display.

  • [original_error] Object optional

    the original error object

Returns:

Bucket.error: instance

get

(
  • keys
  • callback
)
String | Object chainable async

Defined in src/Driver.js:136

Retrieve item or items from the storage.

Parameters:

  • keys String | Array

    which key/keys we want to retrieve

  • callback Function

    A callback function that will handle the results.

Returns:

String | Object: if was asked for a collection of values, return a map, otherwise return a string

getAll

(
  • callback
)
Object chainable async

Defined in src/Driver.js:153

get all items.


  getAll(function callback(Error|null, Object records))
    

Parameters:

  • callback Function
    • A callback function for processing the records

Returns:

Object: key=>value map

getKeys

(
  • callback
)
Array chainable async

Defined in src/Driver.js:172

get all keys.


  getKeys(function callback(Error|null, Array keys))
    

Parameters:

  • callback Function
    • A callback function for processing the keys

Returns:

Array: an array of key names

getLength

(
  • cb
)
Number chainable async

Defined in src/Driver.js:239

returns the number of items in the store

Parameters:

  • cb Function

Returns:

Number:

init

() protected

Defined in src/Driver.js:192

This method will be init the Driver.

Any initialization code should be place here

initTimeout

(
  • [cb]
  • [name]
)
Number protected

Defined in src/Driver.js:292

this method is intended to be used for initializing the timeout counter for the request timeout error

Parameters:

  • [cb] Function optional

    in case we want the timeout error to also trigger a callback

  • [name] String optional

    which method initiated the timeout

Returns:

Number: timeout handle

remove

(
  • keys
  • [callback]
)
chainable async

Defined in src/Driver.js:203

Remove items from the storage

Parameters:

  • keys String | Array
    • The key(s) of the item we want to remove
  • [callback] Function optional

Example:


  remove(String|Array [, function(Error|null)]) - remove the given key(s) from the storage
    

removeEvent

(
  • event
  • function
)
chainable

removes a function from an event

Parameters:

  • event String

    type

  • function Function

    to remove from stack

set

(
  • key
  • [value]
  • [cb]
)
chainable async

Defined in src/Driver.js:223

Add a new item(s) to the storage. If the key is already in the store it will be updated.

Parameters:

  • key String | Object

    if string, will be used as a key name. If object, will be used as a key=>value map

  • [value] String optional

    key value (only used in case of singular set)

  • [cb] Function optional

    will be called when action is done

setOptions

(
  • options
)
chainable

Parameters:

  • options Object

test

()

Defined in src/Driver.js:265

Test method to check if this driver is suitable for this browser/device

Returns:

boolean

Properties

bound

Object protected

holds the generated bound function collection

defaultOptions

Object protected

Inherited from utils.Options but overwritten in src/Driver.js:49

contains a list of default options for the driver

name

String

Defined in src/Driver.js:62

The driver name.

prefix

String protected

Defined in src/Driver.js:70

The storage prefix to allow same keys from different components.

Events

destroy

Defined in src/Driver.js:42

error

Defined in src/Driver.js:35

Event Payload:

load

Defined in src/Driver.js:31