Update record

This commit is contained in:
KGrzeg 2021-10-17 23:00:29 +02:00
parent 6843b76ebf
commit a38072214e
3 changed files with 27 additions and 2 deletions

View file

@ -14,8 +14,7 @@ class Database {
async read() {
await this.db.read();
this.db.data = this.db.data || {
users: [],
records: []
users: []
}
}
@ -32,6 +31,15 @@ class Database {
getUserByPassword(password) {
return this.db.data.users.find(user => user.password === password)
}
async updateRecord(username, record) {
const user = this.db.data.users.find(user => user.name == username)
if (record > user.record) {
user.record = record
await this.db.write()
}
}
}
export default new Database