objects IDs counter refactoring

This commit is contained in:
2026-02-07 11:46:52 +02:00
parent b72d386b73
commit 06d485e63a
6 changed files with 14 additions and 19 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ class MockDb {
this.data = {};
this.lastId = 0;
}
async getLastId() { return this.lastId; }
async getId() { return this.lastId; }
async create(collection, obj) {
this.lastId++;
obj.id = this.lastId;
@@ -43,7 +43,7 @@ class GamesManager {
init(app) {
const db = app.db;
this.create = async (ctx, data) => {
data.id = (await db.getLastId()) + 1;
data.id = await db.getId('games');
await db.create('games', data);
return data;
};