mirror of
https://github.com/JonnyBro/JaBa.git
synced 2025-02-01 07:04:11 +05:00
feat: added new func in database adapter
This commit is contained in:
parent
0ea85ec3ac
commit
f20c7a5550
2 changed files with 32 additions and 0 deletions
|
@ -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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue