-
Notifications
You must be signed in to change notification settings - Fork 9
Datastore.nucleus
Creates a Redis client. The constructor returns a Proxy that interfaces the class and a Promise that resolves once the server is connected.
Adds an item to a hash given a field and its key. HMSET key field value
Parameters
itemKey: String
, Adds an item to a hash given a field and its key. HMSET key field value
itemField: String
, Adds an item to a hash given a field and its key. HMSET key field value
item: *
, Adds an item to a hash given a field and its key. HMSET key field value
hashList: Array
, Adds an item to a hash given a field and its key. HMSET key field value
Returns: Promise.<*>
Adds an item to a list given its key. LPUSH key value
Parameters
itemKey: String
, Adds an item to a list given its key. LPUSH key value
item: *
, Adds an item to a list given its key. LPUSH key value
itemList: Array
, Adds an item to a list given its key. LPUSH key value
Returns: Promise.<*>
Adds an item to a set. SADD key value
Parameters
itemKey: String
, Adds an item to a set. SADD key value
item: String
, Adds an item to a set. SADD key value
Returns: Promise.<*>
Adds a triple to a hexastore.
Parameters
itemKey: String
, Adds a triple to a hexastore.
subject: String
, Adds a triple to a hexastore.
predicate: String
, Adds a triple to a hexastore.
object: String
, Adds a triple to a hexastore.
Returns: Promise.<void>
Creates an item. SET key value
Parameters
itemKey: String
, Creates an item. SET key value
item: *
, Creates an item. SET key value
Returns: Promise.<*>
Destroys the Redis connection.
Returns: Promise
Duplicates the connection.
Parameters
datastoreName: String
, Duplicates the connection.
Returns: NucleusDatastore
Evaluates a LUA script.
Parameters
LUAscript: String
, Evaluates a LUA script.
argumentList: Array
, Evaluates a LUA script.
Returns: Promise.<*>
Executes all handler callback for a given channel name.
Parameters
channelName: String
, Executes all handler callback for a given channel name.
$event: NucleusEvent
, Executes all handler callback for a given channel name.
Returns: Promise
Verifies if an item is part of a given item set.
Parameters
itemKey: String
, Verifies if an item is part of a given item set.
item: String
, Verifies if an item is part of a given item set.
Returns: Promise.<Object>
Handles event published to a specific channel given a handler callback.
Parameters
channelName: String
, Handles event published to a specific channel given a handler callback.
handlerCallback: function
, Handles event published to a specific channel given a handler callback.
Returns: Promise.<Object>
Handles Redis event.
Parameters
argumentList: Array.<String>
, Handles Redis event.
Removes a triple from a hexastore given the subject vector. This will remove every relationship where the given vector is subject or object.
Parameters
itemKey: String
, Removes a triple from a hexastore given the subject vector.
This will remove every relationship where the given vector is subject or object.
vector: String
, Removes a triple from a hexastore given the subject vector.
This will remove every relationship where the given vector is subject or object.
Returns: Promise.<void>
Removes an item given its key. DEL key
Parameters
itemKey: String
, Removes an item given its key. DEL key
Returns: Promise.<null>
Removes an item from a hash given a field. HMDEL key field
Parameters
itemKey: String
, Removes an item from a hash given a field. HMDEL key field
itemField: String
, Removes an item from a hash given a field. HMDEL key field
Returns: Promise.<null>
Retrieves all the items from a hash given its name. HGETALL key
Parameters
itemKey: , Retrieves all the items from a hash given its name. HGETALL key
Returns: Promise.<Array>
Retrieves an item given its key. GET key
Parameters
itemKey: String
, Retrieves an item given its key. GET key
Returns: Promise.<*>
Remove an item from a hash given an item field. HMDEL key field
Parameters
itemKey: String
, Remove an item from a hash given an item field. HMDEL key field
itemField: String
, Remove an item from a hash given an item field. HMDEL key field
itemFieldList: Array.<String>
, Remove an item from a hash given an item field. HMDEL key field
Returns: Promise.<*>
Retrieves an item from a list but blocks the client if the list is empty. BRPOP key timeout
Parameters
itemKey: String
, Retrieves an item from a list but blocks the client if the list is empty. BRPOP key timeout
Returns: Promise
Retrieves the relationship between a subject and an object from a hexastore.
Parameters
itemName: String
, Retrieves the relationship between a subject and an object from a hexastore.
subject: String
, Retrieves the relationship between a subject and an object from a hexastore.
object: String
, Retrieves the relationship between a subject and an object from a hexastore.
Returns: Promise.<Array.<String>>
NucleusDatastore.retrieveVectorByIndexSchemeFromHexastore(itemName, indexingScheme, vectorA, vectorB)
Retrieves the any vector from any triple given the index scheme from a hexastore.
Parameters
itemName: String
, Retrieves the any vector from any triple given the index scheme from a hexastore.
indexingScheme: String
, Retrieves the any vector from any triple given the index scheme from a hexastore.
vectorA: String
, Retrieves the any vector from any triple given the index scheme from a hexastore.
vectorB: String
, Retrieves the any vector from any triple given the index scheme from a hexastore.
Returns: Promise.<Array.<String>>
Example:
async $datastore.addTripleToHexastore('ResourceRelationship', userID, 'isMember', userGroupID);
const relationshipList = async $datastore.retrieveVectorByIndexSchemeFromHexastore('ResourceRelationship', 'SOP', userID, userGroupID);
Subscribes the client to a channel given its name.
Parameters
channelName: String
, Subscribes the client to a channel given its name.
Returns: Promise
Unsubscribes the client from a channel given its name.
Parameters
channelName: String
, Unsubscribes the client from a channel given its name.
Returns: Promise
Parses a hash item list into an object.
Parameters
itemList: Array
, Parses a hash item list into an object.
Returns: Object
Parses an item to a native data type.
Parameters
item: String
, Parses an item to a native data type.
Returns: *
Stringifies a native data type.
Parameters
item: *
, Stringifies a native data type.
Returns: String
Author: Sebastien Filion
Overview: Define the Nucleus Datastore class that wraps a Redis client.
Kind: global class
-
NucleusDatastore
- new NucleusDatastore(datastoreName, options)
-
instance
-
.addItemToHashFieldByName(itemKey, [itemField], [item], [...hashList]) ⇒
Promise.<*>
-
.addItemToListByName(itemKey, item, [itemList]) ⇒
Promise.<*>
-
.addItemToSetByName(itemKey, item) ⇒
Promise.<*>
-
.addTripleToHexastore(itemKey, subject, predicate, object) ⇒
Promise.<void>
-
.createItem(itemKey, item) ⇒
Promise.<*>
-
.destroy() ⇒
Promise
-
.duplicateConnection([datastoreName]) ⇒
NucleusDatastore
-
.evaluateLUAScript(LUAscript, ...argumentList) ⇒
Promise.<*>
-
.executeHandlerCallbackForChannelName(channelName, $event) ⇒
Promise
-
.itemIsMemberOfSet(itemKey, item) ⇒
Promise.<Object>
-
.handleEventByChannelName(channelName, handlerCallback) ⇒
Promise.<Object>
- .handleRedisEvent(...argumentList)
-
.removeAllTriplesFromHexastoreByVector(itemKey, vector) ⇒
Promise.<void>
-
.removeItemByName(itemKey) ⇒
Promise.<null>
-
.removeItemFromFieldByName(itemKey, itemField) ⇒
Promise.<null>
-
.retrieveAllItemsFromHashByName(itemKey) ⇒
Promise.<Array>
-
.retrieveItemByName(itemKey) ⇒
Promise.<*>
-
.retrieveItemFromHashFieldByName(itemKey, [itemField], [...itemFieldList]) ⇒
Promise.<*>
-
.retrieveItemFromListDeferred(itemKey) ⇒
Promise
-
.retrieveRelationshipListFromHexastore(itemName, subject, object) ⇒
Promise.<Array.<String>>
-
.retrieveVectorByIndexSchemeFromHexastore(itemName, indexingScheme, vectorA, vectorB) ⇒
Promise.<Array.<String>>
-
.searchItemInHashByName(itemKey, [fieldName], [fieldNameList]) ⇒
*
-
.subscribeToChannelName(channelName) ⇒
Promise
-
.unsubscribeFromChannelName(channelName) ⇒
Promise
-
.addItemToHashFieldByName(itemKey, [itemField], [item], [...hashList]) ⇒
-
static
-
.collapseObjectToDotNotation(object) ⇒
Object
-
.expandDotNotationObject(object) ⇒
Object
-
.parseHashItem(itemList) ⇒
Object
-
.parseItem(item) ⇒
*
-
.stringifyItem(item) ⇒
String
-
.collapseObjectToDotNotation(object) ⇒
Creates a Redis client. The constructor returns a Proxy that interfaces the class and a Promise that resolves once the server is connected.
Param | Type | Default |
---|---|---|
datastoreName | String |
Untitled |
options | Object |
|
[options.index] | Number |
0 |
[options.port] | Number |
6379 |
[options.URL] | String |
"localhost" |
nucleusDatastore.addItemToHashFieldByName(itemKey, [itemField], [item], [...hashList]) ⇒ Promise.<*>
Adds an item to a hash given a field and its key. HMSET key field value
Kind: instance method of NucleusDatastore
Throws:
- Will throw an error if the item key is missing or an empty string.
- Will throw an error if the item field is missing or an empty string.
- Will throw an error if an inconsistent list of item field and item is passed.
Param | Type |
---|---|
itemKey | String |
[itemField] | String |
[item] | * |
[...hashList] | Array |
Adds an item to a list given its key. LPUSH key value
Kind: instance method of NucleusDatastore
Throws:
- Will throw an error if the item key is missing or an empty string.
Param | Type |
---|---|
itemKey | String |
item | * |
[itemList] | Array |
Adds an item to a set. SADD key value
Kind: instance method of NucleusDatastore
Throws:
- Will throw an error if the item key is missing or an empty string.
- Will throw an error if the item is not a string.
Param | Type |
---|---|
itemKey | String |
item | String |
Adds a triple to a hexastore.
Kind: instance method of NucleusDatastore
Throws:
- Will throw an error if the item key is missing or an empty string.
- Will throw an error if the subject is not a string.
- Will throw an error if the predicate is not a string.
- Will throw an error if the object is not a string.
See: Hexastore paper
Param | Type |
---|---|
itemKey | String |
subject | String |
predicate | String |
object | String |
Creates an item. SET key value
Kind: instance method of NucleusDatastore
Throws:
- Will throw an error if the item key is missing or an empty string.
Param | Type |
---|---|
itemKey | String |
item | * |
Destroys the Redis connection.
Kind: instance method of NucleusDatastore
nucleusDatastore.duplicateConnection([datastoreName]) ⇒ NucleusDatastore
Duplicates the connection.
Kind: instance method of NucleusDatastore
Param | Type | Default |
---|---|---|
[datastoreName] | String |
`${this.name}Duplicate` |
Evaluates a LUA script.
Kind: instance method of NucleusDatastore
Param | Type |
---|---|
LUAscript | String |
...argumentList | Array |
Executes all handler callback for a given channel name.
Kind: instance method of NucleusDatastore
Param | Type |
---|---|
channelName | String |
$event | NucleusEvent |
Verifies if an item is part of a given item set.
Kind: instance method of NucleusDatastore
Throws:
- Will throw an error if the item key is missing or an empty string.
- Will throw an error if the item is not a string.
Param | Type |
---|---|
itemKey | String |
item | String |
Handles event published to a specific channel given a handler callback.
Kind: instance method of NucleusDatastore
Param | Type |
---|---|
channelName | String |
handlerCallback | function |
Handles Redis event.
Kind: instance method of NucleusDatastore
Param | Type |
---|---|
...argumentList | Array.<String> |
Removes a triple from a hexastore given the subject vector. This will remove every relationship where the given vector is subject or object.
Kind: instance method of NucleusDatastore
Throws:
- Will throw an error if the item key is missing or an empty string.
- Will throw an error if the vector is not a string.
Param | Type |
---|---|
itemKey | String |
vector | String |
Removes an item given its key. DEL key
Kind: instance method of NucleusDatastore
Throws:
- Will throw an error if the item key is missing or an empty string.
Param | Type |
---|---|
itemKey | String |
Removes an item from a hash given a field. HMDEL key field
Kind: instance method of NucleusDatastore
Throws:
- Will throw an error if the item key is missing or an empty string.
- Will throw an error if the item field is missing or an empty string.
Param | Type |
---|---|
itemKey | String |
itemField | String |
Retrieves all the items from a hash given its name. HGETALL key
Kind: instance method of NucleusDatastore
Throws:
- Will throw an error if the item key is missing or an empty string.
Param |
---|
itemKey |
Retrieves an item given its key. GET key
Kind: instance method of NucleusDatastore
Throws:
- Will throw an error if the item key is missing or an empty string.
Param | Type |
---|---|
itemKey | String |
nucleusDatastore.retrieveItemFromHashFieldByName(itemKey, [itemField], [...itemFieldList]) ⇒ Promise.<*>
Remove an item from a hash given an item field. HMDEL key field
Kind: instance method of NucleusDatastore
Throws:
- Will throw an error if the item key is missing or an empty string.
- Will throw an error if the item field is missing or an empty string.
Param | Type |
---|---|
itemKey | String |
[itemField] | String |
[...itemFieldList] | Array.<String> |
Retrieves an item from a list but blocks the client if the list is empty. BRPOP key timeout
Kind: instance method of NucleusDatastore
Param | Type |
---|---|
itemKey | String |
nucleusDatastore.retrieveRelationshipListFromHexastore(itemName, subject, object) ⇒ Promise.<Array.<String>>
Retrieves the relationship between a subject and an object from a hexastore.
Kind: instance method of NucleusDatastore
Param | Type |
---|---|
itemName | String |
subject | String |
object | String |
nucleusDatastore.retrieveVectorByIndexSchemeFromHexastore(itemName, indexingScheme, vectorA, vectorB) ⇒ Promise.<Array.<String>>
Retrieves the any vector from any triple given the index scheme from a hexastore.
Kind: instance method of NucleusDatastore
See: Hexastore paper
Param | Type | Default |
---|---|---|
itemName | String |
|
indexingScheme | String |
SPO,SOP,OPS,OSP,PSO,POS |
vectorA | String |
|
vectorB | String |
Example
async $datastore.addTripleToHexastore('ResourceRelationship', userID, 'isMember', userGroupID);
const relationshipList = async $datastore.retrieveVectorByIndexSchemeFromHexastore('ResourceRelationship', 'SOP', userID, userGroupID);
Searches for items in a hash given its name.
Kind: instance method of NucleusDatastore
Param | Type |
---|---|
itemKey | String |
[fieldName] | String |
[fieldNameList] | Array.<String> |
Example
$datastore.searchItemInHashByName('UserSettings', 'localization');
$datastore.searchItemInHashByName('UserSettings', 'localization.defaultLanguageISO');
$datastore.searchItemInHashByName('UserSettings', ['localization', 'notifications');
$datastore.searchItemInHashByName('UserSettings', ['localization.defaultLanguageISO', 'notifications.channels.email']);
Subscribes the client to a channel given its name.
Kind: instance method of NucleusDatastore
Param | Type |
---|---|
channelName | String |
Unsubscribes the client from a channel given its name.
Kind: instance method of NucleusDatastore
Param | Type |
---|---|
channelName | String |
Collaps an object to a dot notation object.
Kind: static method of NucleusDatastore
Param | Type |
---|---|
object | Object |
Example
const collapsedObject = NucleusDatastore.collapseObjectToDotNotation({ a: { b: 'B' } });
collapsedObject['a.b'] === 'B';
Expands a dot notation object.
Kind: static method of NucleusDatastore
Param | Type |
---|---|
object | Object |
Example
const expandedObject = NucleusDatastore.expandDotNotationObject({ 'a.b': 'B' });
expandedObject.a.b === 'B';
Parses a hash item list into an object.
Kind: static method of NucleusDatastore
Param | Type |
---|---|
itemList | Array |
Parses an item to a native data type.
Kind: static method of NucleusDatastore
Param | Type |
---|---|
item | String |
Stringifies a native data type.
Kind: static method of NucleusDatastore
Param | Type |
---|---|
item | * |