feat: add provide and update template
This commit is contained in:
@@ -4,7 +4,7 @@ import { provide } from 'cc-server-ioc'
|
||||
import { DBClient } from 'cc-server-db'
|
||||
|
||||
@provide(DBClient)
|
||||
export class MongoDBClient<T = any> {
|
||||
export class MongoDBClient<T = any> implements DBClient {
|
||||
public db: Db;
|
||||
|
||||
constructor() {
|
||||
@@ -13,6 +13,10 @@ export class MongoDBClient<T = any> {
|
||||
});
|
||||
}
|
||||
|
||||
public getProvide(): Db {
|
||||
return this.db;
|
||||
}
|
||||
|
||||
public async find(collection: string, filter: object): Promise<T[]> {
|
||||
return await this.db.collection(collection).find(filter).toArray();
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export * from './client'
|
||||
export * from './client'
|
||||
export * from 'mongodb';
|
||||
Reference in New Issue
Block a user