@travetto/model-elasticsearch 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/service.ts +10 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-elasticsearch",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Elasticsearch backing for the travetto model module, with real-time modeling support for Elasticsearch mappings.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"elasticsearch",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@elastic/elasticsearch": "^8.15.0",
|
|
31
|
-
"@travetto/config": "^5.0.
|
|
32
|
-
"@travetto/model": "^5.0.
|
|
33
|
-
"@travetto/model-query": "^5.0.
|
|
31
|
+
"@travetto/config": "^5.0.2",
|
|
32
|
+
"@travetto/model": "^5.0.2",
|
|
33
|
+
"@travetto/model-query": "^5.0.2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/command": "^5.0.
|
|
36
|
+
"@travetto/command": "^5.0.2"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/command": {
|
package/src/service.ts
CHANGED
|
@@ -208,13 +208,13 @@ export class ElasticsearchModelService implements
|
|
|
208
208
|
return item;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
async updatePartial<T extends ModelType>(cls: Class<T>, data: Partial<T> & { id: string }): Promise<T> {
|
|
211
|
+
async updatePartial<T extends ModelType>(cls: Class<T>, data: Partial<T> & { id: string }, view?: string): Promise<T> {
|
|
212
212
|
ModelCrudUtil.ensureNotSubType(cls);
|
|
213
213
|
|
|
214
|
-
await ModelCrudUtil.
|
|
214
|
+
const item = await ModelCrudUtil.prePartialUpdate(cls, data, view);
|
|
215
215
|
|
|
216
|
-
const script = ElasticsearchSchemaUtil.generateUpdateScript(
|
|
217
|
-
const id =
|
|
216
|
+
const script = ElasticsearchSchemaUtil.generateUpdateScript(item);
|
|
217
|
+
const id = item.id!;
|
|
218
218
|
|
|
219
219
|
console.debug('Partial Script', { script });
|
|
220
220
|
|
|
@@ -375,10 +375,7 @@ export class ElasticsearchModelService implements
|
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
async * listByIndex<T extends ModelType>(cls: Class<T>, idx: string, body?: DeepPartial<T>): AsyncIterable<T> {
|
|
378
|
-
const cfg = ModelRegistry.getIndex(cls, idx);
|
|
379
|
-
if (cfg.type === 'unique') {
|
|
380
|
-
throw new AppError('Cannot list on unique indices', 'data');
|
|
381
|
-
}
|
|
378
|
+
const cfg = ModelRegistry.getIndex(cls, idx, ['sorted', 'unsorted']);
|
|
382
379
|
let search = await this.execSearch<T>(cls, {
|
|
383
380
|
scroll: '2m',
|
|
384
381
|
size: 100,
|
|
@@ -431,7 +428,7 @@ export class ElasticsearchModelService implements
|
|
|
431
428
|
}
|
|
432
429
|
|
|
433
430
|
// Query Crud
|
|
434
|
-
async
|
|
431
|
+
async updateByQuery<T extends ModelType>(cls: Class<T>, data: T, query: ModelQuery<T>): Promise<T> {
|
|
435
432
|
ModelCrudUtil.ensureNotSubType(cls);
|
|
436
433
|
await QueryVerifier.verify(cls, query);
|
|
437
434
|
|
|
@@ -485,10 +482,12 @@ export class ElasticsearchModelService implements
|
|
|
485
482
|
return res.deleted ?? 0;
|
|
486
483
|
}
|
|
487
484
|
|
|
488
|
-
async
|
|
485
|
+
async updatePartialByQuery<T extends ModelType>(cls: Class<T>, query: ModelQuery<T>, data: Partial<T>): Promise<number> {
|
|
489
486
|
await QueryVerifier.verify(cls, query);
|
|
490
487
|
|
|
491
|
-
const
|
|
488
|
+
const item = await ModelCrudUtil.prePartialUpdate(cls, data);
|
|
489
|
+
|
|
490
|
+
const script = ElasticsearchSchemaUtil.generateUpdateScript(item);
|
|
492
491
|
|
|
493
492
|
const search = ElasticsearchQueryUtil.getSearchObject(cls, query, this.config.schemaConfig);
|
|
494
493
|
const res = await this.client.updateByQuery({
|