K
K
Konstantin2021-05-26 23:35:04
Mongoose
Konstantin, 2021-05-26 23:35:04

How to filter data search with find()?

I have a Post model that contains the field "postId" : "1"

I send a request and I want to find in the model exactly the postId from the request in the postId field
This option const post = await Post.find({ postId:postId}) did not work

router.put("/:postId/edit", async (req, res) => {
    try {
        const post = await Post.find(как вписать фильтры)

    .
    } catch(err) {
        ...
    }
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2021-05-26
@gradk

What type of field? Number? So the query parameter must be brought to a number.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question