Skip to content

Commit c6636e3

Browse files
author
Adrien Maret
authored
Add missing strong types in document controller (#692)
Add strong types for updateByQuery and upsert
1 parent e029db7 commit c6636e3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/controllers/Document.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
KDocumentContentGeneric,
1717
KDocument,
1818
KHit,
19+
mUpsertRequest,
1920
} from '../types';
2021
import { SearchResult } from '../core/searchResult/SearchResultBase';
2122

@@ -551,7 +552,7 @@ export class DocumentController extends BaseController {
551552
mUpsert<TKDocumentContent extends KDocumentContentGeneric> (
552553
index: string,
553554
collection: string,
554-
documents: mUpdateRequest<TKDocumentContent>,
555+
documents: mUpsertRequest<TKDocumentContent>,
555556
options: ArgsDocumentControllerMUpsert = {}
556557
): Promise<mUpdateResponse> {
557558
const request = {
@@ -725,7 +726,7 @@ export class DocumentController extends BaseController {
725726
index: string,
726727
collection: string,
727728
query: JSONObject,
728-
changes: JSONObject,
729+
changes: Partial<TKDocumentContent>,
729730
options: ArgsDocumentControllerUpdateByQuery = {}
730731
): Promise<{
731732
/**
@@ -787,7 +788,7 @@ export class DocumentController extends BaseController {
787788
collection: string,
788789
_id: string,
789790
changes: Partial<TKDocumentContent>,
790-
options: ArgsDocumentControllerUpsert = {}
791+
options: ArgsDocumentControllerUpsert<TKDocumentContent> = {}
791792
): Promise<KDocument<TKDocumentContent>> {
792793
const request = {
793794
index,
@@ -942,8 +943,8 @@ export interface ArgsDocumentControllerUpdateByQuery extends ArgsDefault {
942943
lang?: string;
943944
}
944945

945-
export interface ArgsDocumentControllerUpsert extends ArgsDefault {
946-
default?: JSONObject;
946+
export interface ArgsDocumentControllerUpsert<TKDocumentContent> extends ArgsDefault {
947+
default?: Partial<TKDocumentContent>;
947948
refresh?: string;
948949
silent?: boolean;
949950
retryOnConflict?: boolean;

0 commit comments

Comments
 (0)