diff --git a/src/Typesense/Document.ts b/src/Typesense/Document.ts index c78f0d8e..676af2ab 100644 --- a/src/Typesense/Document.ts +++ b/src/Typesense/Document.ts @@ -5,6 +5,12 @@ import Documents, { DocumentSchema, DocumentWriteParameters, } from "./Documents"; +import { normalizeArrayableParams } from "./Utils"; + +export interface DocumentsRetrieveParameters { + include_fields?: string | string[]; + exclude_fields?: string | string[]; +} export class Document { constructor( @@ -13,8 +19,10 @@ export class Document { private apiCall: ApiCall ) {} - async retrieve(): Promise { - return this.apiCall.get(this.endpointPath()); + async retrieve(options?: DocumentsRetrieveParameters): Promise { + const queryParams = normalizeArrayableParams(options ?? {}) + + return this.apiCall.get(this.endpointPath(), queryParams); } async delete(options?: DeleteQuery): Promise {