Added toke counter to statistics schema

This commit is contained in:
rainbow napkin 2024-12-14 17:21:16 -05:00
parent 80f0c5435f
commit dc01b8a15a
2 changed files with 28 additions and 1 deletions

View file

@ -36,7 +36,19 @@ const statSchema = new mongoose.Schema({
type: mongoose.SchemaTypes.Number,
required: true,
default: 0
}
},
tokes: [{
toke: {
type: mongoose.SchemaTypes.Map,
required: true,
default: new Map()
},
date: {
type: mongoose.SchemaTypes.Date,
required: true,
default: new Date()
}
}]
});
//statics
@ -101,4 +113,15 @@ statSchema.statics.incrementChannelCount = async function(){
return oldCount;
}
statSchema.statics.tattooToke = async function(toke){
//Get the statistics document
const stats = await this.getStats();
//Add the toke to the stat document
stats.tokes.push({toke});
//Save the stat document
await stats.save();
}
module.exports = mongoose.model("statistics", statSchema);