Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

86
Views
Mongoose Array Field Can't Updating

Here is my schema;

...
  group: [
    {
      type: mongoose.Types.ObjectId,
      ref: 'groups'
    }
  ],
...

I'am trying update data. I can update other fields but I can not update group field. My given data;

{
  name: 'John Wick',
  role: '631c8f39fb0d6300ebf2d0c1',
  group: [ '632c770cdabb9fbf70a84efa', '632c76e26fec98665363cc43' ]
}

Name and Role can update but group is not. What should I do?

Edit: Here is my update code;

User.findOneAndUpdate({_id},{{
  name: 'John Wick',
  role: '631c8f39fb0d6300ebf2d0c1',
  group: [ '632c770cdabb9fbf70a84efa', '632c76e26fec98665363cc43' ]
}},{}, (err,doc) => err ? console.log(err) : null)
almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You have double {{ in the second argument of the query. That should be changed with single {:

User.findOneAndUpdate({ _id }, {
  // Data
})
``
almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!