Creates a new instance of the persistence component.
(optional) a table name.
The SQLite connection pool object.
The SQLite connection component.
The SQLite database name.
The dependency resolver.
The logger.
The SQLite table object.
Adds index definition to create it on opening
DML statement to autocreate database object
Clears component state.
(optional) transaction id to trace execution through call chain.
callback function that receives error or null no errors occured.
Closes component and frees used resources.
(optional) transaction id to trace execution through call chain.
callback function that receives error or null no errors occured.
Configures component by passing configuration parameters.
configuration parameters to be set.
Convert object value from public to internal format.
an object in public format to convert.
converted object in internal format.
Converts object value from internal to public format.
an object in internal format to convert.
converted object in public format.
Creates a data item.
an item to be created.
(optional) callback function that receives created item or error.
Deletes data items that match to a given filter.
This method shall be called by a public deleteByFilter method from child class that receives FilterParams and converts them into a filter function.
(optional) transaction id to trace execution through call chain.
(optional) a filter JSON object.
(optional) callback function that receives error or null for success.
Adds index definition to create it on opening
index keys (fields)
index options
Generates a list of column names to use in SQL statements like: "column1,column2,column3"
an array with column values or a key-value map
a generated list of column names
Generates a list of value parameters to use in SQL statements like: "$1,$2,$3"
an array with values or a key-value map
a generated list of value parameters
Generates a list of column sets to use in UPDATE statements like: column1=$1,column2=$2
a key-value map with columns and values
a generated list of column sets
Generates a list of column parameters
a key-value map with columns and values
a generated list of column values
Gets a number of data items retrieved by a given filter.
This method shall be called by a public getCountByFilter method from child class that receives FilterParams and converts them into a filter function.
(optional) transaction id to trace execution through call chain.
(optional) a filter JSON object
callback function that receives a data page or error.
Gets a list of data items retrieved by a given filter and sorted according to sort parameters.
This method shall be called by a public getListByFilter method from child class that receives FilterParams and converts them into a filter function.
(optional) transaction id to trace execution through call chain.
(optional) a filter JSON object
(optional) sorting JSON object
(optional) projection JSON object
callback function that receives a data list or error.
Gets a random item from items that match to a given filter.
This method shall be called by a public getOneRandom method from child class that receives FilterParams and converts them into a filter function.
(optional) transaction id to trace execution through call chain.
(optional) a filter JSON object
callback function that receives a random item or error.
Gets a page of data items retrieved by a given filter and sorted according to sort parameters.
This method shall be called by a public getPageByFilter method from child class that receives FilterParams and converts them into a filter function.
(optional) transaction id to trace execution through call chain.
(optional) a filter JSON object
(optional) paging parameters
(optional) sorting JSON object
(optional) projection JSON object
callback function that receives a data page or error.
Checks if the component is opened.
true if the component has been opened and false otherwise.
Opens the component.
(optional) transaction id to trace execution through call chain.
callback function that receives error or null no errors occured.
Sets references to dependent components.
references to locate the component dependencies.
Unsets (clears) previously set references to dependent components.
Generated using TypeDoc
Abstract persistence component that stores data in SQLite using plain driver.
This is the most basic persistence component that is only able to store data items of any type. Specific CRUD operations over the data items must be implemented in child classes by accessing
this._db
orthis._collection
properties.Configuration parameters
References
*:logger:*:*:1.0
(optional) ILogger components to pass log messages*:discovery:*:*:1.0
(optional) IDiscovery services*:credential-store:*:*:1.0
(optional) Credential stores to resolve credentialsExample
class MySqlitePersistence extends SqlitePersistence<MyData> { public constructor() { base("mydata"); } public getByName(correlationId: string, name: string, callback: (err, item) => void): void { let criteria = { name: name }; this._model.findOne(criteria, callback); }); public set(correlatonId: string, item: MyData, callback: (err) => void): void { let criteria = { name: item.name }; let options = { upsert: true, new: true }; this._model.findOneAndUpdate(criteria, item, options, callback); } } let persistence = new MySqlitePersistence(); persistence.configure(ConfigParams.fromTuples( "host", "localhost", "port", 27017 )); persitence.open("123", (err) => { ... }); persistence.set("123", { name: "ABC" }, (err) => { persistence.getByName("123", "ABC", (err, item) => { console.log(item); // Result: { name: "ABC" } }); });