1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-09-30 00:50:59 -04:00
Daggerbot-TS/src/models/MPServer.ts

26 lines
828 B
TypeScript
Raw Normal View History

2023-02-26 18:45:56 -05:00
import TClient from 'src/client';
import mongoose from 'mongoose';
const Schema = mongoose.model('mpserver', new mongoose.Schema({
_id: {type: String, required:true},
ip: {type: String},
code: {type: String},
timesUpdated: {type: Number, required: true}
}, {versionKey: false}));
export default class MPServer extends Schema {
client: TClient;
_content: typeof Schema;
constructor(client:TClient){
super();
this.client = client;
this._content = Schema;
}
async _increment(serverId: string){
const server = await this._content.findById(serverId)
if (server) await this._content.findByIdAndUpdate(server, {timesUpdated: server.timesUpdated + 1})
else await this._content.create({_id:serverId, timesUpdated: 1})
//console.log(`[${serverId}] :: timesUpdated value incremented`)
}
}