Fix bug 366 (#764)

* Optimize DB

* Clean up names

* fixup! Clean up names

* fixup! fixup! Clean up names
This commit is contained in:
Chris 2026-01-07 18:18:07 +02:00 committed by GitHub
parent b4de9c23eb
commit 542be2c1e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
175 changed files with 8503 additions and 5587 deletions

View file

@ -0,0 +1,46 @@
'use strict';
/**
* Base repository class providing common data access methods.
* Extend this class to create entity-specific repositories.
*/
class BaseRepository {
constructor(model) {
this.model = model;
}
async findById(id, options = {}) {
return this.model.findByPk(id, options);
}
async findOne(where, options = {}) {
return this.model.findOne({ where, ...options });
}
async findAll(where = {}, options = {}) {
return this.model.findAll({ where, ...options });
}
async create(data, options = {}) {
return this.model.create(data, options);
}
async update(instance, data, options = {}) {
return instance.update(data, options);
}
async destroy(instance, options = {}) {
return instance.destroy(options);
}
async count(where = {}, options = {}) {
return this.model.count({ where, ...options });
}
async exists(where) {
const count = await this.count(where);
return count > 0;
}
}
module.exports = BaseRepository;