In my MongoDB collection, each document has three variables:
const moneySchema = mongoose.Schema({
userID: String,
tron: Number,
sccn: Number
})
Using JavaScript, I need to increase the value of sccn by (tron * multiplier) every hour where the multiplier is a pre-defined variable.
I know how to schedule the hourly event, but I'm unsure how to handle the increment operation. This is what I have tried so far:
Money.updateMany(
{ },
{ $inc: { "sccn": { $mul: { "tron": sccnpertrx } } } } }
).catch(err => console.log(err));