import CatchRecordModel, { type CatchRecord } from '$lib/models/CatchRecord'; class CatchRecordRepository { async findById(id: string): Promise { return CatchRecordModel.findById(id).exec(); } async findAll(): Promise { return CatchRecordModel.find().exec(); } async create(data: Partial): Promise { return CatchRecordModel.create(data); } async update(id: string, data: Partial): Promise { return CatchRecordModel.findByIdAndUpdate(id, data, { new: true }).exec(); } async delete(id: string): Promise { await CatchRecordModel.findByIdAndDelete(id).exec(); } async upsert(data: Partial): Promise { if (data._id) { // Update existing record return CatchRecordModel.findByIdAndUpdate(data._id, data, { new: true }).exec(); } else { // Create new record return CatchRecordModel.create(data); } } } export default CatchRecordRepository;