Interface: RepositoryInterface

RepositoryInterface

Interface for classes that model a collection of domain objects with querying capabilities

Methods

(async) count() → {Promise.<number>}

Count the total number of records in the repository For performance reasons, use this method rather than counting the number of entries returned by #findAll if you only need the size of a repository
Source:
Returns:
Promise that will be resolved with the total number of records
Type
Promise.<number>

(async) finalize() → {Promise.<Repository>}

[Optional] Finalize repository Override this method if the repository needs some asynchronous code to properly close the repository (close database connection, push changes on Git remote…)
Source:
Returns:
Promise that will be resolved with the current repository instance
Type
Promise.<Repository>

(async) findAll() → {Promise.<Array.<Record>>}

Find all records For performance reasons, the content of the records will not be loaded by default. Use #loadRecordContent to load the content of individual records
Source:
See:
Returns:
Promise that will be resolved with an array of all records
Type
Promise.<Array.<Record>>

(async) findByDate(serviceId, termsType, date, documentIdopt) → {Promise.<Record>}

Find the record that was valid on the given date and that matches the given service ID and terms type and optionally the document ID In case of snapshots, if the record is related to terms extracted from multiple source documents, the document ID is required to find the source snapshot
Parameters:
Name Type Attributes Description
serviceId string Service ID of record to find
termsType string Terms type of record to find
date date Datetime on which the record to find was valid
documentId string <optional>
Document ID of record to find. Used to identify the source in terms extracted from multiple source documents. Not necessary for terms with a single source document
Source:
Returns:
Promise that will be resolved with the found record or an empty object if none match the given criteria
Type
Promise.<Record>

(async) findById(recordId) → {Promise.<Record>}

Find the record that matches the given record ID
Parameters:
Name Type Description
recordId string Record ID of the record to find
Source:
Returns:
Promise that will be resolved with the found record or an empty object if none match the given ID
Type
Promise.<Record>

(async) findLatest(serviceId, termsType, documentIdopt) → {Promise.<Record>}

Find the most recent record that matches the given service ID and terms type and optionally the document ID In case of snapshots, if the record is related to terms extracted from multiple source documents, the document ID is required to find the source snapshot
Parameters:
Name Type Attributes Description
serviceId string Service ID of record to find
termsType string Terms type of record to find
documentId string <optional>
Document ID of record to find. Used to identify the source in terms extracted from multiple source documents. Not necessary for terms with a single source document
Source:
Returns:
Promise that will be resolved with the found record or an empty object if none match the given criteria
Type
Promise.<Record>

(async) initialize() → {Promise.<Repository>}

[Optional] Initialize repository Override this method if the repository needs some asynchronous initialization code (open database connection and create collections, initialize Git…)
Source:
Returns:
Promise that will be resolved with the current repository instance
Type
Promise.<Repository>

(async, generator) iterate() → {Record}

Iterate over all records in the repository, from oldest to most recent
Source:
Yields:
Type
Record

(async) loadRecordContent(record) → {Promise.<Record>}

Load content of the given record
Parameters:
Name Type Description
record Record Record of which to populate content
Source:
Returns:
Promise that will be resolved with the given record when its content has been loaded
Type
Promise.<Record>

(async) removeAll() → {Promise}

Remove all records
Source:
Returns:
Promise that will be resolved when all records are removed
Type
Promise

(async) save(record) → {Promise.<Record>}

Persist the given record if it does not already exist in repository
Parameters:
Name Type Description
record Record Record to persist
Source:
Returns:
Promise that will be resolved with the given record when it has been persisted
Type
Promise.<Record>