1

I'm trying to update the favorite Boolean to true in the following model.

I only need a success/failure return, so I've been trying update with a projection. However, I can't seem to get any further than selecting articles, but am not able to change the favorite value given the title name.

I am using the mongoDB node.js driver

Thanks!

_id: id,
news: [
    { 
      name: bbc,
      articles: [
                  {
                    title: 'flashpoint', favorite: false
                  }
                ]
    }
]

1 Answer 1

2

You're actually hitting one of the limitations of MongoDB, a Ticket on their Jira was opened in 2010 regarding updating items in deeply nested arrays, and has just been implemented, stated for release with Mongo 3.5.12. If you're using an older version, the simplest solution would be to go for a second collection containing your articles (with references on the first collection), so you can update them directly.

Sign up to request clarification or add additional context in comments.

2 Comments

Awesome Nicolas, thanks a lot for the answer and pointing me in the right direction!
My pleasure, don't hesitate to Accept my answer if it answers your question, the mods will thank you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.