this works on localhost

This commit is contained in:
Hri7566 2022-12-06 07:30:36 -05:00
parent eafca18a05
commit eb34607c3e
1 changed files with 12 additions and 0 deletions

View File

@ -58,6 +58,10 @@ class Database {
} }
static async createUser(_id) { static async createUser(_id) {
if (!this.userdb) {
await this.load();
}
let user = new UserModel({ let user = new UserModel({
name: "Anonymous", name: "Anonymous",
_id: _id, _id: _id,
@ -71,6 +75,10 @@ class Database {
} }
static async updateUser(_id, data) { static async updateUser(_id, data) {
if (!this.userdb) {
await this.load();
}
let user = await UserModel.findOne({_id: _id}).exec(); let user = await UserModel.findOne({_id: _id}).exec();
user.name = data.name; user.name = data.name;
@ -82,6 +90,10 @@ class Database {
} }
static async wipe() { static async wipe() {
if (!this.userdb) {
await this.load();
}
await UserModel.find({}, (err, docs) => { await UserModel.find({}, (err, docs) => {
docs.forEach(doc => { docs.forEach(doc => {
doc.remove(); doc.remove();