From cb44036e4b06078e78b736aad4c76c5f0bbdcad6 Mon Sep 17 00:00:00 2001 From: Denys Date: Mon, 2 Feb 2026 19:51:00 +0000 Subject: [PATCH] fix: add ability to include/exclude fields for a single document retrieval --- src/Typesense/Document.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 {