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

263
Views
Cómo fusionar dos Mongoose Arrays dentro de Document en el método findByIdAndUpdate Typescript Express

Tiene este modelo

 export const IEventSchema = new mongoose.Schema<IEventBase>({ type: {type: String, enum: EventType, required: true}, date: {type: Number, required: true}, title: {type: String}, description: {type: String}, notifiedUsers: [ { type: Schema.Types.ObjectId, ref: 'User', default: {} } ], unnotifiedUsers: [ { type: Schema.Types.ObjectId, ref: 'User', default: {} } ], });

Quiero mover el contenido de la matriz de usuarios notificados a usuarios no notificados, dentro del método findByIdAndUpdate del enrutador.

 router.put('/delay/:id', async (req: Request, res: Response) => { try { await Event.findByIdAndUpdate(req.params.id, { $set: {date: req.body.date}, // Write Here } ); res.status(200).json(`Event delayed to ${req.body.date}`); } catch (e: any) { console.log(e); } });
 $addToSet: {unnotifiedUsers: {$each: 'notifiedUsers'}} // Does not working
about 4 years ago · Juan Pablo Isaza
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!