Skip to content

Commit 7ce5fea

Browse files
authored
master <- fixed limit/offset type bug
since the limit/offset param is number but represented as string, mongod complains that it can't use it. a simple solution for my use case, since I'm using pagination in the API
1 parent 38f1c3e commit 7ce5fea

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

server/core/context.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,15 @@ class Context {
572572
*/
573573
queryPageSort(query) {
574574
if (this.params) {
575-
if (this.params.limit)
576-
query.limit(this.params.limit);
575+
if (this.params.limit) {
576+
let limit = parseInt(this.params.limit);
577+
query.limit(limit);
578+
}
577579

578-
if (this.params.offset)
579-
query.skip(this.params.offset);
580+
if (this.params.offset) {
581+
let offset = parseInt(this.params.offset);
582+
query.skip(offset);
583+
}
580584

581585
if (this.params.sort)
582586
query.sort(this.params.sort.replace(/,/, " "));

0 commit comments

Comments
 (0)