Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Typesense/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends DocumentSchema = object> {
constructor(
Expand All @@ -13,8 +19,10 @@ export class Document<T extends DocumentSchema = object> {
private apiCall: ApiCall
) {}

async retrieve(): Promise<T> {
return this.apiCall.get<T>(this.endpointPath());
async retrieve(options?: DocumentsRetrieveParameters): Promise<T> {
const queryParams = normalizeArrayableParams(options ?? {})

return this.apiCall.get<T>(this.endpointPath(), queryParams);
}

async delete(options?: DeleteQuery): Promise<T> {
Expand Down