Class: TDataBaseManager

TDataBaseManager

The base class of database managers. Give the basic interface about database call.

new TDataBaseManager()

Author:
License:
Source:
Requires:
Example
Todo

Requires

Members


<private, static> _requestId :number

Type:
  • number
Source:

<private, static> _requests :Object

Type:
  • Object
Source:

<static> requestId

Source:

basePath

Source:

bunchSize

Source:

logger

Source:

requestAggregationTime

Source:

requestsConcurrency

Source:

responseType

Source:

Methods


<private> _closeRequest(request)

Will remove the request from the process queue
Parameters:
Name Type Description
request
Source:

<private> _createMany(datas, onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
datas
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<private> _createOne(data, onLoadCallback, onProgressCallback, onErrorCallback)

The private _create method allow to format a server request to create objects with the given data and get creation result with given callbacks.
Parameters:
Name Type Description
data object The data to send.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _deleteAll(onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<private> _deleteMany(ids, onLoadCallback, onProgressCallback, onErrorCallback)

The private _deleteMany method will format a server request to delete objects with id in the ids array.
Parameters:
Name Type Description
ids array.<string> The ids of objects to delete.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _deleteOne(id, onLoadCallback, onProgressCallback, onErrorCallback)

The private _deleteOne method will format a server request to delete a single object with the given id.
Parameters:
Name Type Description
id string The object's id of the object to delete.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _deleteWhere(query, onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
query
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<private> _dispatchResponse(response, responseType, onLoadCallback, onProgressCallback, onErrorCallback)

Dispatch response to the correct handler in function of response type
Parameters:
Name Type Description
response
responseType
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<abstract, private> _onArrayBuffer(data, onSuccess, onProgress, onError)

The abstract private _onArrayBuffer method must be overridden in case the parser expect an array buffer as input data.
Parameters:
Name Type Description
data ArrayBuffer The retrieved data to parse.
onSuccess function The onLoad callback, which is call when parser parse with success the data.
onProgress function The onProgress callback, which is call during the parsing.
onError function The onError callback, which is call when parser throw an error during parsing.
Source:

<abstract, private> _onBlob(data, onSuccess, onProgress, onError)

The abstract private _onBlob method must be overridden in case the parser expect a blob as input data.
Parameters:
Name Type Description
data Blob The retrieved data to parse.
onSuccess function The onLoad callback, which is call when parser parse with success the data.
onProgress function The onProgress callback, which is call during the parsing.
onError function The onError callback, which is call when parser throw an error during parsing.
Source:

<private> _onEnd(request, onLoadCallback, response)

The private _onEnd method is call after all other callback and perform request type checking in view to upadte cache, waitingqueue and callback if needed, to finally close the request
Parameters:
Name Type Description
request
onLoadCallback
response
Source:

<private> _onError(onErrorCallback, errorEvent)

The private _onError method will handle all error event from server and submit them to the logger if exist else to the user onErrorCallback
Parameters:
Name Type Description
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
errorEvent object A server error event
Source:

<abstract, private> _onJson(data, onSuccess, onProgress, onError)

The abstract private _onJson method must be overridden in case the parser expect json as input data.
Parameters:
Name Type Description
data json The retrieved data to parse.
onSuccess function The onLoad callback, which is call when parser parse with success the data.
onProgress function The onProgress callback, which is call during the parsing.
onError function The onError callback, which is call when parser throw an error during parsing.
Source:

<private> _onLoad(onLoadCallback, onProgressCallback, onErrorCallback, loadEvent)

The private _onLoad method allow to process the server response in an abstract way to check against error and wrong status code. It will bind user callback on each type of returns, and dispatch in sub methods in function of the response type.
Parameters:
Name Type Description
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
loadEvent object The server response object to parse.
Source:

<private> _onProgress(onProgressCallback, progressEvent)

The private _onProgress method will handle all progress event from server and submit them to the logger if exist else to the user onProgressCallback
Parameters:
Name Type Description
onProgressCallback function The onProgress callback, which is call during the response incoming.
progressEvent object The server progress event.
Source:

<abstract, private> _onText(data, onSuccess, onProgress, onError)

The abstract private _onText method must be overridden in case the parser expect a string/text as input data.
Parameters:
Name Type Description
data string The retrieved data to parse.
onSuccess function The onLoad callback, which is call when parser parse with success the data.
onProgress function The onProgress callback, which is call during the parsing.
onError function The onError callback, which is call when parser throw an error during parsing.
Source:

<private> _readAll(projection, onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
projection
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<private> _readMany(ids, onLoadCallback, onProgressCallback, onErrorCallback)

The private _readMany method will format a server request to get objects with id in the ids array.
Parameters:
Name Type Description
ids array.<string> The ids of objects to retrieve.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _readOne(id, onLoadCallback, onProgressCallback, onErrorCallback)

The private _updateOne method will format a server request to get a single object with the given id.
Parameters:
Name Type Description
id string The object's id of the object to retrieve.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _readWhere(query, projection, onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
query
projection
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<private> _retrieveCachedValues(ids)

Parameters:
Name Type Description
ids
Source:
Returns:
Type
Object

<private> _updateAll(update, onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
update
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<private> _updateCache(datas)

Parameters:
Name Type Description
datas
Source:

<private> _updateMany(ids, update, onLoadCallback, onProgressCallback, onErrorCallback)

The private _updateMany method will format a server request to update objects with id in the ids array.
Parameters:
Name Type Description
ids array.<string> The ids of objects to update.
update
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _updateOne(id, update, onLoadCallback, onProgressCallback, onErrorCallback)

The private _updateOne method will format a server request to update a single object with the given id.
Parameters:
Name Type Description
id string The object's id of the object to update.
update
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _updateWaitingQueue()

Source:

<private> _updateWhere(query, update, onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
query
update
onLoadCallback
onProgressCallback
onErrorCallback
Source:

aggregateQueue()

Source:

create(data, onLoadCallback, onProgressCallback, onErrorCallback)

The create method allow to create a new ressource on the server. Providing a single object that match a database schema, or an array of them.
Parameters:
Name Type Description
data object | array.<object> The data to send for create new objects.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

delete(condition, onLoadCallback, onProgressCallback, onErrorCallback)

The delete method allow to remove data from the server, using a single id or an array of them.
Parameters:
Name Type Description
condition string | array.<string> | object | null The ids of objects to delete.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

processQueue()

Source:

read(condition, onLoadCallback, onProgressCallback, onErrorCallback)

The read method allow to retrieve data from the server, using a single id or an array of them.
Parameters:
Name Type Description
condition string | array.<string> The ids of objects to retrieve.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

setBasePath(value)

Parameters:
Name Type Description
value
Source:
Returns:
Type
TDataBaseManager

setBunchSize(value)

Parameters:
Name Type Description
value
Source:
Returns:
Type
TDataBaseManager

setLogger(value)

Parameters:
Name Type Description
value
Source:
Returns:
Type
TDataBaseManager

setRequestAggregationTime(value)

Parameters:
Name Type Description
value
Source:
Returns:
Type
TDataBaseManager

setRequestsConcurrency(value)

Parameters:
Name Type Description
value
Source:
Returns:
Type
TDataBaseManager

setResponseType(value)

Parameters:
Name Type Description
value
Source:
Returns:
Type
TDataBaseManager

update(condition, update, onLoadCallback, onProgressCallback, onErrorCallback)

The update method allow to update data on the server, using a single id or an array of them, and a corresponding object about the data to update.
Parameters:
Name Type Description
condition string | array.<string> The ids of objects to update.
update object The update data ( need to match the related database schema ! ). In case of multiple ids they will be updated with the same given data.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

Class: TDataBaseManager

TDataBaseManager


new TDataBaseManager(parameters)

Parameters:
Name Type Description
parameters
Source:

Members


<private, static> _requestId :number

Type:
  • number
Source:

<private, static> _requests :Object

Type:
  • Object
Source:

<static> requestId

Source:

basePath

Source:

bunchSize

Source:

logger

Source:

requestAggregationTime

Source:

requestsConcurrency

Source:

responseType

Source:

Methods


<private> _closeRequest(request)

Will remove the request from the process queue
Parameters:
Name Type Description
request
Source:

<private> _createMany(datas, onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
datas
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<private> _createOne(data, onLoadCallback, onProgressCallback, onErrorCallback)

The private _create method allow to format a server request to create objects with the given data and get creation result with given callbacks.
Parameters:
Name Type Description
data object The data to send.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _deleteAll(onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<private> _deleteMany(ids, onLoadCallback, onProgressCallback, onErrorCallback)

The private _deleteMany method will format a server request to delete objects with id in the ids array.
Parameters:
Name Type Description
ids array.<string> The ids of objects to delete.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _deleteOne(id, onLoadCallback, onProgressCallback, onErrorCallback)

The private _deleteOne method will format a server request to delete a single object with the given id.
Parameters:
Name Type Description
id string The object's id of the object to delete.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _deleteWhere(query, onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
query
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<private> _dispatchResponse(response, responseType, onLoadCallback, onProgressCallback, onErrorCallback)

Dispatch response to the correct handler in function of response type
Parameters:
Name Type Description
response
responseType
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<abstract, private> _onArrayBuffer(data, onSuccess, onProgress, onError)

The abstract private _onArrayBuffer method must be overridden in case the parser expect an array buffer as input data.
Parameters:
Name Type Description
data ArrayBuffer The retrieved data to parse.
onSuccess function The onLoad callback, which is call when parser parse with success the data.
onProgress function The onProgress callback, which is call during the parsing.
onError function The onError callback, which is call when parser throw an error during parsing.
Source:

<abstract, private> _onBlob(data, onSuccess, onProgress, onError)

The abstract private _onBlob method must be overridden in case the parser expect a blob as input data.
Parameters:
Name Type Description
data Blob The retrieved data to parse.
onSuccess function The onLoad callback, which is call when parser parse with success the data.
onProgress function The onProgress callback, which is call during the parsing.
onError function The onError callback, which is call when parser throw an error during parsing.
Source:

<private> _onEnd(request, onLoadCallback, response)

The private _onEnd method is call after all other callback and perform request type checking in view to upadte cache, waitingqueue and callback if needed, to finally close the request
Parameters:
Name Type Description
request
onLoadCallback
response
Source:

<private> _onError(onErrorCallback, errorEvent)

The private _onError method will handle all error event from server and submit them to the logger if exist else to the user onErrorCallback
Parameters:
Name Type Description
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
errorEvent object A server error event
Source:

<abstract, private> _onJson(data, onSuccess, onProgress, onError)

The abstract private _onJson method must be overridden in case the parser expect json as input data.
Parameters:
Name Type Description
data json The retrieved data to parse.
onSuccess function The onLoad callback, which is call when parser parse with success the data.
onProgress function The onProgress callback, which is call during the parsing.
onError function The onError callback, which is call when parser throw an error during parsing.
Source:

<private> _onLoad(onLoadCallback, onProgressCallback, onErrorCallback, loadEvent)

The private _onLoad method allow to process the server response in an abstract way to check against error and wrong status code. It will bind user callback on each type of returns, and dispatch in sub methods in function of the response type.
Parameters:
Name Type Description
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
loadEvent object The server response object to parse.
Source:

<private> _onProgress(onProgressCallback, progressEvent)

The private _onProgress method will handle all progress event from server and submit them to the logger if exist else to the user onProgressCallback
Parameters:
Name Type Description
onProgressCallback function The onProgress callback, which is call during the response incoming.
progressEvent object The server progress event.
Source:

<abstract, private> _onText(data, onSuccess, onProgress, onError)

The abstract private _onText method must be overridden in case the parser expect a string/text as input data.
Parameters:
Name Type Description
data string The retrieved data to parse.
onSuccess function The onLoad callback, which is call when parser parse with success the data.
onProgress function The onProgress callback, which is call during the parsing.
onError function The onError callback, which is call when parser throw an error during parsing.
Source:

<private> _readAll(projection, onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
projection
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<private> _readMany(ids, onLoadCallback, onProgressCallback, onErrorCallback)

The private _readMany method will format a server request to get objects with id in the ids array.
Parameters:
Name Type Description
ids array.<string> The ids of objects to retrieve.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _readOne(id, onLoadCallback, onProgressCallback, onErrorCallback)

The private _updateOne method will format a server request to get a single object with the given id.
Parameters:
Name Type Description
id string The object's id of the object to retrieve.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _readWhere(query, projection, onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
query
projection
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<private> _retrieveCachedValues(ids)

Parameters:
Name Type Description
ids
Source:
Returns:
Type
Object

<private> _updateAll(update, onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
update
onLoadCallback
onProgressCallback
onErrorCallback
Source:

<private> _updateCache(datas)

Parameters:
Name Type Description
datas
Source:

<private> _updateMany(ids, update, onLoadCallback, onProgressCallback, onErrorCallback)

The private _updateMany method will format a server request to update objects with id in the ids array.
Parameters:
Name Type Description
ids array.<string> The ids of objects to update.
update
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _updateOne(id, update, onLoadCallback, onProgressCallback, onErrorCallback)

The private _updateOne method will format a server request to update a single object with the given id.
Parameters:
Name Type Description
id string The object's id of the object to update.
update
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

<private> _updateWaitingQueue()

Source:

<private> _updateWhere(query, update, onLoadCallback, onProgressCallback, onErrorCallback)

Parameters:
Name Type Description
query
update
onLoadCallback
onProgressCallback
onErrorCallback
Source:

aggregateQueue()

Source:

create(data, onLoadCallback, onProgressCallback, onErrorCallback)

The create method allow to create a new ressource on the server. Providing a single object that match a database schema, or an array of them.
Parameters:
Name Type Description
data object | array.<object> The data to send for create new objects.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

delete(condition, onLoadCallback, onProgressCallback, onErrorCallback)

The delete method allow to remove data from the server, using a single id or an array of them.
Parameters:
Name Type Description
condition string | array.<string> | object | null The ids of objects to delete.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

processQueue()

Source:

read(condition, onLoadCallback, onProgressCallback, onErrorCallback)

The read method allow to retrieve data from the server, using a single id or an array of them.
Parameters:
Name Type Description
condition string | array.<string> The ids of objects to retrieve.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source:

setBasePath(value)

Parameters:
Name Type Description
value
Source:
Returns:
Type
TDataBaseManager

setBunchSize(value)

Parameters:
Name Type Description
value
Source:
Returns:
Type
TDataBaseManager

setLogger(value)

Parameters:
Name Type Description
value
Source:
Returns:
Type
TDataBaseManager

setRequestAggregationTime(value)

Parameters:
Name Type Description
value
Source:
Returns:
Type
TDataBaseManager

setRequestsConcurrency(value)

Parameters:
Name Type Description
value
Source:
Returns:
Type
TDataBaseManager

setResponseType(value)

Parameters:
Name Type Description
value
Source:
Returns:
Type
TDataBaseManager

update(condition, update, onLoadCallback, onProgressCallback, onErrorCallback)

The update method allow to update data on the server, using a single id or an array of them, and a corresponding object about the data to update.
Parameters:
Name Type Description
condition string | array.<string> The ids of objects to update.
update object The update data ( need to match the related database schema ! ). In case of multiple ids they will be updated with the same given data.
onLoadCallback function The onLoad callback, which is call when server respond with success to the request.
onProgressCallback function The onProgress callback, which is call during the response incoming.
onErrorCallback function The onError callback, which is call when server respond with an error to the request.
Source: