0

I have an application with data. They are stored in a mongo model. But when I try to find by username like this:

`

 app. get('/profile/:name', function(req, res) {
        var name = req.params.name
        ModelAccount.findOne({
            user info: {
                username: name
            }
        })

` mongo sends me null. I think the problem is because my data is stored in 2 JSON objects but I'm not funding anything to fix this. So I need your help ^^ sorry it's my first post on this website so that explain my texts form tysm

Laaw
  • 1

1 Answers1

0

Try this

app.get('/profile/:name',  async(req, res)=> {
        let name = req.params.name
        await ModelAccount.findOne({
            user_info.username: name
        })
Vivek Rahul
  • 314
  • 2
  • 15