feat: added new func in database adapter

This commit is contained in:
Slincnik 2024-12-14 16:38:28 +03:00
parent 0ea85ec3ac
commit f20c7a5550
No known key found for this signature in database
2 changed files with 32 additions and 0 deletions

View file

@ -6,4 +6,20 @@ export default class IDatabaseAdapter {
async disconnect() { async disconnect() {
throw new Error("Method `disconnect` not implemented."); throw new Error("Method `disconnect` not implemented.");
} }
async find() {
throw new Error("Method \"find\" must be implemented");
}
async findOne() {
throw new Error("Method \"findOne\" must be implemented");
}
async updateOne() {
throw new Error("Method \"updateOne\" must be implemented");
}
async deleteOne() {
throw new Error("Method \"deleteOne\" must be implemented");
}
} }

View file

@ -29,4 +29,20 @@ export default class MongooseAdapter extends IDatabaseAdapter {
await mongoose.disconnect(); await mongoose.disconnect();
logger.warn("Database disconnected."); logger.warn("Database disconnected.");
} }
async find(model, query = {}, options = {}) {
return model.find(query, null, options).exec();
}
async findOne(model, query = {}, options = {}) {
return model.findOne(query, null, options).exec();
}
async updateOne(model, filter, update, options = {}) {
return model.updateOne(filter, update, options).exec();
}
async deleteOne(model, filter) {
return model.deleteOne(filter).exec();
}
} }