Push items into mongo array via mongoose

前端 未结 8 1588
小鲜肉
小鲜肉 2020-11-22 03:22

I\'ve scoured SO a good bit looking for the answer but I\'m sure that I\'m lost for the right words to describe what I\'m after.

Basically I have a mongodb collection

8条回答
  •  生来不讨喜
    2020-11-22 04:05

    In my case, I did this

      const eventId = event.id;
      User.findByIdAndUpdate(id, { $push: { createdEvents: eventId } }).exec();
    

提交回复
热议问题