Data Store
Classes
- Access
Access contains a set of standard methods for getting and setting data for any database
- AppState
The AppState allows the using application to store its current state in a common way, as well as any app specific data needed.
This is expecting a Database Adapter as its argument. It is assumed that the AppState owns the root of the database, as destroy() will remove it.
Structure : { status : { state : 'initializing' | 'started' | ... info : 'sub state' detail : { } updated : timestamp } app : { } }
- DeviceStore
Returns a new DeviceStore class that is used to access the various bins of a Device's information
- Access
Returns a new FirebaseStore class that will use the firebase library passed in. This should be either 'firebase' (on browser) or 'firebase-admin' on server.
- FirebaseStore
contains many methods for interacting with the firebase database
- RootStore
Returns a new SystemStore class that is used to access the various bins of a Device's information
- SystemStore
Returns a new SystemStore class that is used to access the various bins of a Device's information
Functions
- _refFor returns the ref for a child or the current ref(path)
- child returns an access object for the child(path)
- on starts an on listener(path, onComplete, onCancelled, cxt)
- off starts an off listener(path, callback, cxt)
- onAdd starts a listener for when a child is added(path, onComplete, onCancelled, cxt)
- offAdd starts a listener for when a child is added(path, callback, cxt)
- onRemove start a listener for when a child is removed(path, onComplete, onCancelled, cxt)
- offRemove start a listener for when a child is removed(path, callback, cxt)
- once make a one time query to the database for information(path, onComplete, onError)
- set sets the value at the given path(path, value, onComplete)
- push pushes the value at the given path(path, value, onComplete)
- update updates the value at the given path(path, value, onComplete)
- remove the data at the given path(path, onComplete)
- timestampValue returns the timestamp of the server()
- destroy Complete removes the state for this app(onComplete)
- signIn sign in to the database()
- setState sets the status state(value, onComplete)
- setInfo Sets an optional sub-state value into the status block(value, onComplete)
- getInfo gets info from the database(onComplete, onError)
- setDetailData sets the value at the path(path, value, onComplete)
- removeDetailData removes the data at the path(path, onComplete)
- getDetailData gets the data on the path(path, onComplete, onError, cxt)
- getStatus Returns a Promise that is querying the app for its full status.(onComplete, onError)
- onStatus Listens for changes to the status object(onComplete, onCancel)
- offStatus Listens for changes to the status object(callback)
- setAppData sets app data at the path(path, value, onComplete)
- getAppData gets the app data at the path(path, onComplete, onError)
- onAppData listen for changes to the app data(path, onComplete, onCancel)
- offAppData listen for changes to the app data(path, callback)
- updateAppData updates the app data(path, value, onComplete)
- removeAppData removes the app data at the path(path, value, onComplete)
- sign in with a custom jwt token(jwt)
- using the specified class(path, ClassType)
- access Creates an Access object referencing the location retrive to the current root(path)
- an Access object pointing to
/srv/ is created(name) - timestampValue returns the timestamp of the server()
- appByName searchs firebase instance for an app with the name(firebase, name)
- registerDatabase adds a database class to the databases object(type, clzz)
- registerLib adds a library to the lib object(type, lib)
- createRootStore creates a store with the root store class(options)
- createSystemStore creates a store with the system store class(options)
- createDeviceStore creates a store with the device store class(options)
- createAppState Creates an AppState object from the given arguments:(options, name)
- data returns an instance of access for getting data()
- meta returns an instance of access for getting the meta()
- events returns an instance of access for getting events()
- outbound returns an instance of access for outbound data()
- device returns an instance of access for devices()
- cache returns an instance of access for the cache()
- init creates and returns an instance of a class for interacting with the database(firebase)
- _refFor returns the reference for the given path(path)
- child returns an access object for the provided path(path)
- on starts a listener on the provided path(path, onComplete, onCancelled, cxt)
- off starts a listener on the provided path(path, callback, cxt)
- onAdd starts a listener on the provided path for children being added(path, onComplete, onCancelled, cxt)
- offAdd starts a listener on the path for children being added(path, callback, cxt)
- onRemove starts a listener for children being removed(path, onComplete, onCancelled, cxt)
- offRemove starts a listener for children being removed(path, callback, cxt)
- once makes a one time call to the database for information(path, onComplete, onError)
- set sets the value at the path(path, value, onComplete)
- update updates the value at the path(path, value, onComplete)
- remove removes the value at the path(path, onComplete)
- timestampValue returns the timestamp of the firebase server()
- _refFor gets a database reference for the path(path)
- _metaRefFor gets a database reference for the meta data of the path(path)
- _serviceRefFor gets a database reference for the service data of the path(path)
- sign in with a custom jwt token(jwt)
- child returns a new FirebaseStore with the a new root(path)
- data returns a new Access object to the data root()
- meta returns a new Access object to the meta root()
- device returns a new Accees object to the device root()
- access Creates an Access object referencing the location reative to the current root(path)
- on creates a listener for when the data at the path is changed(path, onComplete, onCancelled, cxt)
- off create a listener for when the data at the path is changed(path, callback, cxt)
- once get the data one time(path, onComplete, onError)
- set sets the data at the path(path, value, onComplete)
- update updates the data at the path(path, value, onComplete)
- remove removes the data at the path(path, onComplete)
- metaOn adds a listener to the meta data at the path(path, onComplete, onCancelled, cxt)
- metaOff adds a listener to the meta data at the path(path, callback, cxt)
- metaOnce gets the meta data once(path, onComplete, onError)
- metaSet sets the meta data(path, value, onComplete)
- metaUpdate updates the meta data(path, value, onComplete)
- metaRemove removes the meta at the path(path, onComplete)
- timestampValue gets the timestamp of the database()
- appByName gets a firebase app based off its name(name)
- Creates a DeviceStore for the systems device(dev)
- deviceStore Creates a DeviceStore for the systems device(dev)
Access
Access contains a set of standard methods for getting and setting data for any database
Kind: global class
new Access(ref, firebase)
Param | Type | Description |
---|---|---|
ref | object | contains all the methods for interacting with the database |
firebase | object | firebase database object |
new Access(ref)
Param | Type | Description |
---|---|---|
ref | object | object with methods to interact with the database |
AppState
The AppState allows the using application to store its current state in a common way, as well as any app specific data needed.
This is expecting a Database Adapter as its argument. It is assumed that the AppState owns the root of the database, as destroy() will remove it.
Structure : { status : { state : 'initializing' | 'started' | ... info : 'sub state' detail : { } updated : timestamp } app : { } }
DeviceStore
Returns a new DeviceStore class that is used to access the various bins of a Device's information
Access
Returns a new FirebaseStore class that will use the firebase library passed in. This should be either 'firebase' (on browser) or 'firebase-admin' on server.
Kind: global class
new Access(ref, firebase)
Param | Type | Description |
---|---|---|
ref | object | contains all the methods for interacting with the database |
firebase | object | firebase database object |
new Access(ref)
Param | Type | Description |
---|---|---|
ref | object | object with methods to interact with the database |
FirebaseStore
contains many methods for interacting with the firebase database
new FirebaseStore(options)
Param | Type | Description |
---|---|---|
options | object | firebase config |
RootStore
Returns a new SystemStore class that is used to access the various bins of a Device's information
SystemStore
Returns a new SystemStore class that is used to access the various bins of a Device's information
_refFor returns the ref for a child or the current ref(path)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | null for current ref or child string for a child |
child returns an access object for the child(path)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path for the child |
on starts an on listener(path, onComplete, onCancelled, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to listen on |
onComplete | function | |
onCancelled | function | |
cxt | object |
off starts an off listener(path, callback, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to listen on |
callback | function | |
cxt | object |
onAdd starts a listener for when a child is added(path, onComplete, onCancelled, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to listen on |
onComplete | function | |
onCancelled | function | |
cxt | object |
offAdd starts a listener for when a child is added(path, callback, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to listen on |
callback | function | |
cxt | object |
onRemove start a listener for when a child is removed(path, onComplete, onCancelled, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to listen on |
onComplete | function | |
onCancelled | function | |
cxt | object |
offRemove start a listener for when a child is removed(path, callback, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to listen on |
callback | function | |
cxt | object |
once make a one time query to the database for information(path, onComplete, onError)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to listen on |
onComplete | function | |
onError | function |
set sets the value at the given path(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to set the value on |
value | any | the value to set |
onComplete | function |
push pushes the value at the given path(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to push the value to |
value | any | the value to be pushed |
onComplete | function |
update updates the value at the given path(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to update the data at |
value | any | the value to be updated |
onComplete | function |
remove the data at the given path(path, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to remove the data at |
onComplete | function |
timestampValue returns the timestamp of the server()
destroy Complete removes the state for this app(onComplete)
Kind: global function
Param | Type |
---|---|
onComplete | function |
signIn sign in to the database()
setState sets the status state(value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
value | any | value to set the state to |
onComplete | function |
setInfo Sets an optional sub-state value into the status block(value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
value | any | value to set the info to |
onComplete | function |
getInfo gets info from the database(onComplete, onError)
Kind: global function
Param | Type |
---|---|
onComplete | function |
onError | function |
setDetailData sets the value at the path(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to set the value at |
value | any | data to set at the path |
onComplete | function |
removeDetailData removes the data at the path(path, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to remove the data at |
onComplete | function |
getDetailData gets the data on the path(path, onComplete, onError, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to get the data from |
onComplete | function | |
onError | function | |
cxt | any |
getStatus Returns a Promise that is querying the app for its full status.(onComplete, onError)
Kind: global function
Param | Type |
---|---|
onComplete | function |
onError | function |
onStatus Listens for changes to the status object(onComplete, onCancel)
Kind: global function
Param | Type |
---|---|
onComplete | function |
onCancel | function |
offStatus Listens for changes to the status object(callback)
Kind: global function
Param | Type |
---|---|
callback | function |
setAppData sets app data at the path(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to set the data at |
value | any | data to be set |
onComplete | function |
getAppData gets the app data at the path(path, onComplete, onError)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to get the data at |
onComplete | function | |
onError | function |
onAppData listen for changes to the app data(path, onComplete, onCancel)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to listen to app data at |
onComplete | function | |
onCancel | function |
offAppData listen for changes to the app data(path, callback)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to listen to app data at |
callback | function |
updateAppData updates the app data(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to update the data at |
value | any | value to update the app data to |
onComplete | function |
removeAppData removes the app data at the path(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to remove the data at |
value | any | not used? |
onComplete | function |
access Creates an Access object referencing the location retrive to the current root(path)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | data path |
timestampValue returns the timestamp of the server()
appByName searchs firebase instance for an app with the name(firebase, name)
Kind: global function
Param | Type | Description |
---|---|---|
firebase | object | |
name | string | name of firebase app to search for |
registerDatabase adds a database class to the databases object(type, clzz)
Kind: global function
Param | Type | Description |
---|---|---|
type | string | the look up string for the database |
clzz | class | the class for creating databases |
registerLib adds a library to the lib object(type, lib)
Kind: global function
Param | Type | Description |
---|---|---|
type | string | the string that lib gets registered under |
lib | any | the library to be registered |
createRootStore creates a store with the root store class(options)
Kind: global function
Param | Type |
---|---|
options | object |
createSystemStore creates a store with the system store class(options)
Kind: global function
Param | Type |
---|---|
options | object |
createDeviceStore creates a store with the device store class(options)
Kind: global function
Param | Type |
---|---|
options | object |
createAppState Creates an AppState object from the given arguments:(options, name)
Kind: global function
Param | Description |
---|---|
options | either a config object, or a database |
name | the name of AppState to attach too. If null/undefined the options.appName or db.options.appName will be used. |
data returns an instance of access for getting data()
meta returns an instance of access for getting the meta()
events returns an instance of access for getting events()
outbound returns an instance of access for outbound data()
device returns an instance of access for devices()
cache returns an instance of access for the cache()
init creates and returns an instance of a class for interacting with the database(firebase)
Kind: global function
Param | Type |
---|---|
firebase | object |
_refFor returns the reference for the given path(path)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to return the ref of |
child returns an access object for the provided path(path)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to return the new access object for |
on starts a listener on the provided path(path, onComplete, onCancelled, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to start the listener on |
onComplete | function | |
onCancelled | function | |
cxt | object |
off starts a listener on the provided path(path, callback, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to start the listener |
callback | function | |
cxt | object |
onAdd starts a listener on the provided path for children being added(path, onComplete, onCancelled, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to listen on |
onComplete | function | |
onCancelled | function | |
cxt | object |
offAdd starts a listener on the path for children being added(path, callback, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path for the listener |
callback | function | |
cxt | object |
onRemove starts a listener for children being removed(path, onComplete, onCancelled, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path for the listener |
onComplete | function | |
onCancelled | function | |
cxt | object |
offRemove starts a listener for children being removed(path, callback, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path for the listener |
callback | function | |
cxt | object |
once makes a one time call to the database for information(path, onComplete, onError)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to get |
onComplete | function | |
onError | function |
set sets the value at the path(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to set |
value | any | value that will be set |
onComplete | function |
update updates the value at the path(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to update |
value | any | value that will be updated |
onComplete | function |
remove removes the value at the path(path, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path of the data to be removed |
onComplete | function |
timestampValue returns the timestamp of the firebase server()
_refFor gets a database reference for the path(path)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to get a database reference for |
_metaRefFor gets a database reference for the meta data of the path(path)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to get the meta for |
_serviceRefFor gets a database reference for the service data of the path(path)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to get the service for |
child returns a new FirebaseStore with the a new root(path)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | appended to the current root to make the root of the new FirebaseStore |
data returns a new Access object to the data root()
meta returns a new Access object to the meta root()
device returns a new Accees object to the device root()
access Creates an Access object referencing the location reative to the current root(path)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path for a new access object |
on creates a listener for when the data at the path is changed(path, onComplete, onCancelled, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to the desired data to be listened to |
onComplete | function | |
onCancelled | function | |
cxt | object |
off create a listener for when the data at the path is changed(path, callback, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to the desired data to be listened to |
callback | function | |
cxt | object |
once get the data one time(path, onComplete, onError)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to get the data from |
onComplete | function | |
onError | function |
set sets the data at the path(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to set the value at |
value | any | value to set |
onComplete | function |
update updates the data at the path(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to update the value of |
value | any | value to update |
onComplete | function |
remove removes the data at the path(path, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to remove |
onComplete | function |
metaOn adds a listener to the meta data at the path(path, onComplete, onCancelled, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to listen to the meta on |
onComplete | function | |
onCancelled | function | |
cxt | object |
metaOff adds a listener to the meta data at the path(path, callback, cxt)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to listen to the meta |
callback | function | |
cxt | object |
metaOnce gets the meta data once(path, onComplete, onError)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to get the meta from |
onComplete | function | |
onError | function |
metaSet sets the meta data(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to set the meta on |
value | any | the data to set at the path |
onComplete | function |
metaUpdate updates the meta data(path, value, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | the path to update the meta on |
value | any | the data to update the meta with |
onComplete | function |
metaRemove removes the meta at the path(path, onComplete)
Kind: global function
Param | Type | Description |
---|---|---|
path | string | path to remove the meta on |
onComplete | function |
timestampValue gets the timestamp of the database()
appByName gets a firebase app based off its name(name)
Kind: global function
Param | Type | Description |
---|---|---|
name | string | firebase app to use |
Creates a DeviceStore for the systems device(dev)
Kind: global function
Param | Description |
---|---|
dev | either th id of the device, or a device object that contains an id field |
deviceStore Creates a DeviceStore for the systems device(dev)
Kind: global function
Param | Description |
---|---|
dev | either th id of the device, or a device object that contains an id field |