feat: return Provide Typed
This commit is contained in:
		@@ -7,7 +7,7 @@ import { DBClient } from 'cc-server-db'
 | 
				
			|||||||
export class MongoDBClient<T = any> implements DBClient {
 | 
					export class MongoDBClient<T = any> implements DBClient {
 | 
				
			||||||
    private table: string;
 | 
					    private table: string;
 | 
				
			||||||
    private db: Db;
 | 
					    private db: Db;
 | 
				
			||||||
    private collection: Collection;
 | 
					    private collection: Collection<T>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor() {
 | 
					    constructor() {
 | 
				
			||||||
        MongoDBConnection.getConnection((connection) => {
 | 
					        MongoDBConnection.getConnection((connection) => {
 | 
				
			||||||
@@ -18,8 +18,8 @@ export class MongoDBClient<T = any> implements DBClient {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public getProvide(): Db {
 | 
					    public getProvide<P>(): P {
 | 
				
			||||||
        return this.db;
 | 
					        return this.db as {} as P;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public setTable(table: string): void {
 | 
					    public setTable(table: string): void {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
export const DBClient = Symbol.for('DBClient')
 | 
					export const DBClient = Symbol.for('DBClient')
 | 
				
			||||||
export interface DBClient<T = any> {
 | 
					export interface DBClient<T = any> {
 | 
				
			||||||
    getProvide(): any;
 | 
					    getProvide<P>(): P;
 | 
				
			||||||
    setTable(table: string): void;
 | 
					    setTable(table: string): void;
 | 
				
			||||||
    find(filter: object): Promise<T[]>;
 | 
					    find(filter: object): Promise<T[]>;
 | 
				
			||||||
    findOne(filter: Object): Promise<T>;
 | 
					    findOne(filter: Object): Promise<T>;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user