Skip to content

Commit 392f8ff

Browse files
committed
feat(query): implement set custom query params
1 parent 47f4d31 commit 392f8ff

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/lib/query.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ interface QueryOptions<DocType> {
5959
limit?: number;
6060
offset?: number;
6161
raw?: boolean;
62+
queryParams?: Record<string, any>;
6263
}
6364

6465

@@ -123,6 +124,10 @@ class Query<ResultType, DocType> {
123124

124125
options!: QueryOptions<DocType>;
125126

127+
queryParams!: (
128+
params: Record<string, any>,
129+
) => this;
130+
126131
raw!: () => this extends Query<infer ResultType, infer ResultDocType>
127132
? ResultType extends RawResultType<any> ? this : Query<RawResultType<ResultType>, ResultDocType>
128133
: never;
@@ -255,6 +260,7 @@ Query.prototype.buildParams = function () {
255260
limit: options.limit,
256261
offset: options.offset,
257262
},
263+
...options.queryParams,
258264
};
259265
};
260266

@@ -392,6 +398,13 @@ Query.prototype.offset = function (offset) {
392398
return this;
393399
};
394400

401+
Query.prototype.queryParams = function (params) {
402+
this.setOptions({
403+
queryParams: params,
404+
});
405+
return this;
406+
};
407+
395408
Query.prototype.raw = function () {
396409
this.setOptions({
397410
raw: true,

0 commit comments

Comments
 (0)