1
0
Fork 0

feat: return Provide Typed

master
MiaoWoo 2019-06-12 18:58:46 +08:00
parent 9fdb56dadb
commit a99a7b9d3b
3 changed files with 4 additions and 4 deletions

0
cli.sh Normal file → Executable file
View File

View File

@ -7,7 +7,7 @@ import { DBClient } from 'cc-server-db'
export class MongoDBClient<T = any> implements DBClient {
private table: string;
private db: Db;
private collection: Collection;
private collection: Collection<T>;
constructor() {
MongoDBConnection.getConnection((connection) => {
@ -18,8 +18,8 @@ export class MongoDBClient<T = any> implements DBClient {
});
}
public getProvide(): Db {
return this.db;
public getProvide<P>(): P {
return this.db as {} as P;
}
public setTable(table: string): void {

View File

@ -1,6 +1,6 @@
export const DBClient = Symbol.for('DBClient')
export interface DBClient<T = any> {
getProvide(): any;
getProvide<P>(): P;
setTable(table: string): void;
find(filter: object): Promise<T[]>;
findOne(filter: Object): Promise<T>;