mongodb-collection-query-with-mongoose
v2.0.22
Published
This is use to query a single mongodb collection written with mongoose dynamically with simple query parameters using mongodb query types 'AND' and 'OR' with mongodb filter options eg '$gt' as 'gt', '$gte' as 'gte', '$lt' as 'lt', '$lte' as 'lte', '$eq'
Downloads
102
Maintainers
Readme
router.get("/post", async (req, res) => {
try {
const setect = "_id title userId description imageUrl"
const response = await Promise.all([getResReq(query, Post, select)]);
const { data, type, msg, status } = response[0];
if (type === "error")
return res
.status(status)
.send({ message: internal server error
, error: msg });
return res.send(data);
} catch {
return res.status(500).send({ message : internal server error
, error: data })
}
});
// note any mongodb query will work just specify the query at the "data" and doc field at "field " and this can also be done from the client as well if you so which.