Tardis
Temporal property implementation for
reading historized data.
Installation
npm install @georges-tech/tardis
Usage
You create a Tardis service through createHistoryService
by providing an array of documents that must contain
the following properties :
{
effective_date: Date
known_at: Date
}
You can add as much properties as you like, depending on your use case, that will be returned by services.
Documents may contain a computed end_date
, being the next effective document date if it exists. Otherwise, it
is undefined
.
Example
import tardis from '@georges-tech/tardis';
const documents = [{
effective_date: new Date('2020-01-01'),
known_at: new Date('2020-05-01'),
data: {
value: 'old',
}
}, {
effective_date: new Date('2020-03-01'),
known_at: new Date('2020-10-01'),
data: {
value: 'new',
}
}]
const historyService = tardis.createHistoryService({ documents });
const januaryConfiguration = historyService.getConfigurationAtDate({ date: new Date('2020-01-03') });
const mayConfiguration = historyService.getConfigurationAtDate({ date: new Date('2020-05-03') });