- Source:
- See:
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
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…)
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
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 |
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 |
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 |
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…)
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
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 |
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
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 |
Returns:
Promise that will be resolved with the given record when it has been persisted
- Type
- Promise.<Record>