Creates a new instance of the persistence.
(optional) a persister component that loads and saves data from/to flat file.
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.
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.
Saves items to external data source using configured saver component.
(optional) transaction id to trace execution through call chain.
(optional) callback function that receives error or null for success.
Sets references to dependent components.
references to locate the component dependencies.
Generated using TypeDoc
Abstract persistence component that stores data in flat files and caches them in memory.
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._items property and calling save method.
MemoryPersistence
JsonFilePersister
Configuration parameters
References
*:logger:*:*:1.0
(optional) ILogger components to pass log messagesExample
class MyJsonFilePersistence extends FilePersistence<MyData> { public constructor(path?: string) { super(new JsonPersister(path)); } public getByName(correlationId: string, name: string, callback: (err, item) => void): void { let item = _.find(this._items, (d) => d.name == name); callback(null, item); }); public set(correlatonId: string, item: MyData, callback: (err) => void): void { this._items = _.filter(this._items, (d) => d.name != name); this._items.push(item); this.save(correlationId, callback); } }