Skip to content

Commit

Permalink
Merge pull request #143 from sliit-foss/patch/mongoose-filter-query
Browse files Browse the repository at this point in the history
Patch!: updated parsing of select and include
  • Loading branch information
Akalanka47000 authored Jan 24, 2024
2 parents c0a43a7 + f1aaef0 commit ecdab62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/mongoose-filter-query/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const mongooseFilterQuery = (req, res, next) => {
} else {
req.query.sort = {};
}
req.query.include = req.query.include?.split(",") ?? [];
req.query.select = req.query.select?.split(",")?.join(" ") ?? "";
req.query.include = req.query.include?.split(",");
req.query.select = req.query.select?.split(",")?.join(" ");
} catch (e) {
console.error("[ FilterQuery ] - Failed to parse query", e);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/mongoose-filter-query/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe("test mongoose-filter-query", () => {
});
test("undefined", async () => {
mongooseFilterQuery(req, {}, () => {});
expect(req.query.include).toEqual([]);
expect(req.query.include).toEqual(undefined);
});
});
describe("select", () => {
Expand All @@ -56,7 +56,7 @@ describe("test mongoose-filter-query", () => {
});
test("undefined", async () => {
mongooseFilterQuery(req, {}, () => {});
expect(req.query.select).toEqual("");
expect(req.query.select).toEqual(undefined);
});
});
test("handle error", async () => {
Expand Down

0 comments on commit ecdab62

Please sign in to comment.