0

I need help with mongoose please. I would like to modify in an object, but I don't know how to do it. Can someone help me please?

PS : ActorId return 1

I have tried :

const user = await userModel.updateOne({ ActorId: ActorId }, { "Mood.FigureAnimation": request.mood.FigureAnimation, "Mood.FaceAnimation": request.mood.FaceAnimation, "Mood.MouthAnimation": request.mood.MouthAnimation, "Mood.MoodText": request.mood.TextLine });

Here is my request :

{
  mood: {
    ActorId: 1,
    FigureAnimation: 'stand',
    FaceAnimation: 'neutral',
    MouthAnimation: 'none',
    TextLine: 'hello',
    SpeechLine: false
  },
  TicketHeader: {
    Ticket: '1,1621847572744,SECRET'
  }
}

Here is my Shema :

Mood: {
  FigureAnimation: String,
  FaceAnimation: String,
  MouthAnimation: String,
  TextLine: String
}

Here is my DB

Thank you in advance for your answer!

cypolo
  • 17
  • 6
  • const user = await userModel.updateOne({ ActorId: ActorId }, {$set:{ "Mood.FigureAnimation": request.mood.FigureAnimation, "Mood.FaceAnimation": request.mood.FaceAnimation, "Mood.MouthAnimation": request.mood.MouthAnimation, "Mood.MoodText": request.mood.TextLine }}); – Babak Abadkheir May 24 '21 at 10:20
  • Does this answer your question? [Updating nested object in mongoose](https://stackoverflow.com/questions/23832921/updating-nested-object-in-mongoose) – Avani Khabiya May 25 '21 at 06:06

0 Answers0