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.
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 function to filter items.
(optional) callback function that receives error or null for success.
Gets a number of 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 function to filter items
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 function to filter items
(optional) sorting parameters
(optional) projection parameters (not used yet)
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 function to filter items.
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 function to filter items
(optional) paging parameters
(optional) sorting parameters
(optional) projection parameters (not used yet)
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.
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); } }