feat: return Provide Typed
This commit is contained in:
parent
9fdb56dadb
commit
a99a7b9d3b
@ -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 {
|
||||
|
@ -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>;
|
||||
|
Loading…
Reference in New Issue
Block a user