-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathdynamic-searcher.ts
27 lines (25 loc) · 1.11 KB
/
dynamic-searcher.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { EntitySearcher } from './entity-searcher.js';
import { Meta } from './meta.js';
import { RemovalResult } from '../dynamic-searchers/removal-result.js';
/**
* A dynamic searcher that, in addition to indexing and searching, can also remove and upsert entities.
* @typeParam TEntity The type of the entities.
* @typeParam TId The type of the entity ids.
*/
export interface DynamicSearcher<TEntity, TId> extends EntitySearcher<TEntity, TId> {
/**
* Removes all present entities with the given ids.
* @param ids The ids of the entities to remove.
* @returns The removal result containing the ids of the entities that were present
* and thus removed.
*/
removeEntities(ids: TId[]): RemovalResult<TId>;
/**
* Updates or inserts the given entities.
* @param entities The entities to update or insert.
* @param getId A function that returns the id of an entity.
* @param getTerms A function that returns the terms of an entity.
* @returns The meta data of the operation.
*/
upsertEntities(entities: TEntity[], getId: (entity: TEntity) => TId, getTerms: (entity: TEntity) => string[]): Meta;
}