feat: add provide and update template

This commit is contained in:
2019-06-11 16:11:34 +08:00
parent 829ca19b4a
commit 177c001bb8
5 changed files with 48 additions and 11 deletions

View File

@@ -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();
}

View File

@@ -1 +1,2 @@
export * from './client'
export * from './client'
export * from 'mongodb';