0

So I am just trying to replicate something that you can do using the mongodb driver (the first answer), Update MongoDB field using value of another field

db.collection.<update method>(
    {},
    [
        {
          "$set": {   
             "todayHours" : "$tomorrowHours",
            "tomorrowHours" : "2" 
          }
        }
    ]
)

The code I have on mongoose is

this.userModel.updateMany({},{
            "todayHours" : "$tomorrowHours",
            "tomorrowHours" : "2"
})

But it won't work as expected Any ideas?

ferluis
  • 122
  • 1
  • 7

1 Answers1

0

should be like:

.updateMany(
   {'your condition here'},
   {$set:{
            todayHours : "$tomorrowHours",
            tomorrowHours : "2"
         }
   }
)
Karl L
  • 1,645
  • 1
  • 7
  • 11