Class: GeneralUserDBWrapperImpl

GeneralUserDBWrapperImpl()

USER METHODS default implementations

This class adds methods that deal directly with possible user storage and lookup tables. The methods defined in the class are used by the class GeneralAuth found in general_auth.js in particular.

The default behavior is for the user to be stored in the persistence DB, which is most likely to be implemented by a connection to a DB service. Except there is one method fetch_user_from_key_value_store that is used to get user information from the key-value DB, which is expected to be faster (in local memory).

Some applcations may want to override this class in order to change the kind of user table storage arrangement from what is provided here. Even without the override, the constuctor expects that objects linking to external databases to be parameters.

Within the user methods, the user object, u_data (often) is expected to have an identity field, _id.

Constructor

new GeneralUserDBWrapperImpl()

Source:

Methods

(async) fetch_user(id, cb) → {object}

Parameters:
Name Type Description
id string
cb function
Source:
Returns:
  • the user object stored in the DB
Type
object

(async) fetch_user_from_key_value_store(key) → {object|boolean}

Some applications may elect to store user in the KV store. That is not the default behavior. The default behavior is to store the user in the persistence DB.

Parameters:
Name Type Description
key string
Source:
Returns:
  • returns false on failing to find an object
Type
object | boolean

id_hashing(user_txt) → {string}

Parameters:
Name Type Description
user_txt string
Source:
Returns:

an unique id for a stored object

Type
string

(async) put_user_into_key_value_store(key, u_data) → {boolean}

This is supplied to provide the parenthetical to the method fetch_user_from_key_value_store

Parameters:
Name Type Description
key string
u_data object
Source:
Returns:
  • false on error
Type
boolean

(async) store_user(u_data, key, cb) → {string}

Parameters:
Name Type Description
u_data object
key string
cb function
Source:
Returns:

an unique id for a stored object

Type
string

(async) update_user(u_data, id_key, cb)

Parameters:
Name Type Description
u_data object
id_key string
cb function
Source: