So I have a MongoDB collection where there are three variables for every document:
const moneySchema = mongoose.Schema({
userID: String,
tron: Number,
sccn: Number
})
Every hour with JavaScript I want to increase the sccn value by (tron * multiplier) with multiplier being a previously defined variable.
I am aware on how to schedule the hourly event but how would I do the increment? I have done this so far.
Money.updateMany(
{ },
{ $inc: { "sccn": { $mul: { "tron": sccnpertrx } } } } }
).catch(err => console.log(err));