diff --git a/packages/mongoose-filter-query/src/index.js b/packages/mongoose-filter-query/src/index.js index 2158959..f0f6282 100644 --- a/packages/mongoose-filter-query/src/index.js +++ b/packages/mongoose-filter-query/src/index.js @@ -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); } diff --git a/packages/mongoose-filter-query/test/index.test.js b/packages/mongoose-filter-query/test/index.test.js index e4b206d..d19eb7c 100644 --- a/packages/mongoose-filter-query/test/index.test.js +++ b/packages/mongoose-filter-query/test/index.test.js @@ -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", () => { @@ -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 () => {