Skip to content

Commit 6de2efe

Browse files
Vikram KaltaVikram Kalta
authored andcommitted
feat: added addParams support for entry class
1 parent 0cd8ea6 commit 6de2efe

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

src/lib/entry.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export class Entry {
1010
private _urlPath: string;
1111
protected _variants: string;
1212
_queryParams: { [key: string]: string | number | string[] } = {};
13-
1413
constructor(client: AxiosInstance, contentTypeUid: string, entryUid: string) {
1514
this._client = client;
1615
this._contentTypeUid = contentTypeUid;
@@ -195,4 +194,25 @@ export class Entry {
195194

196195
return response;
197196
}
197+
198+
/**
199+
* @method addParams
200+
* @memberof BaseQuery
201+
* @description Adds a query parameter to the query.
202+
* @example
203+
* import contentstack from '@contentstack/delivery-sdk'
204+
*
205+
* const stack = contentstack.stack({ apiKey: "apiKey", deliveryToken: "deliveryToken", environment: "environment" });
206+
* const query = stack.contentType("contentTypeUid").entry().query();
207+
* const result = await query.addParams({"key": "value"}).find()
208+
* // OR
209+
* const asset = await stack.asset().addParams({"key": "value"}).find()
210+
*
211+
* @returns {Entry}
212+
*/
213+
addParams(paramObj: { [key: string]: string | number | string[] }): Entry {
214+
this._queryParams = { ...this._queryParams, ...paramObj };
215+
216+
return this;
217+
}
198218
}

0 commit comments

Comments
 (0)