'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;