I want to make GET request that returns data from Postgres database without specifying in advanced the where clause.
router.get("/:object_query", async (req, res) => {
var object_query = req.params.object_query;
var note = await db.note.findAll({
where: object_query
});
if (!note.length) {
return res.status(404).send();
}
res.send({
note
});
});
Call for the request would be something like this:
localhost/note/{objectID: "1234"}
or
localhost/note/{objectID: "1234", otherparam: "abcd"}
Idea is that I can from same request query table with different rows.
Is something like this possible without writing request for each different number of params I plan to use for where clause, as I had an idea?
How should it be done, from my tries I got
(node:23832) UnhandledPromiseRejectionWarning: Error: Support for `{where: 'raw query'}` has been removed.
Thank you for help.