node-flint
Version:
Bot SDK for Node JS
57 lines (50 loc) • 1.95 kB
JavaScript
// template for creating custom storage modules
;
module.exports = exports = function() {
return {
/**
* Store key/value data.
*
* This method is exposed as bot.store(key, value);
*
* @function
* @param {String} id - Room/Conversation/Context ID
* @param {String} key - Key under id object
* @param {(String|Number|Boolean|Array|Object)} value - Value of key
* @returns {(Promise.<String>|Promise.<Number>|Promise.<Boolean>|Promise.<Array>|Promise.<Object>)}
*/
store: function(id, key, value) {
// if id does not exist, create
// if success, return promise that resolves to value
// if failure, returns a rejected promise
},
/**
* Recall value of data stored by 'key'.
*
* This method is exposed as bot.recall(key);
*
* @function
* @param {String} id - Room/Conversation/Context ID
* @param {String} [key] - Key under id object (optional). If key is not passed, all keys for id are returned as an object.
* @returns {(Promise.<String>|Promise.<Number>|Promise.<Boolean>|Promise.<Array>|Promise.<Object>)}
*/
recall: function(id, key) {
// if exists, returns promise that resolves to value of id/key referenced
// if does not exist, or a failure, returns a rejected promise
},
/**
* Forget a key or entire store.
*
* This method is exposed as bot.forget(key);
*
* @function
* @param {String} id - Room/Conversation/Context ID
* @param {String} [key] - Key under id object (optional). If key is not passed, id and all children are removed.
* @returns {(Promise.<String>|Promise.<Number>|Promise.<Boolean>|Promise.<Array>|Promise.<Object>)}
*/
forget: function(id, key) {
// if exists, returns promise that resolves to value of deleted value
// if does not exist, or a failure, returns a rejected promise
}
};
};