refactor: query methods should accept generic for return type (#9957)

* query should accept generics

* Update DataSource.ts
This commit is contained in:
Eliya Cohen 2023-04-18 20:54:08 +03:00 committed by GitHub
parent 0e56f0fcf8
commit f5b93c14b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -515,11 +515,11 @@ export class DataSource {
/**
* Executes raw SQL query and returns raw database results.
*/
async query(
async query<T = any>(
query: string,
parameters?: any[],
queryRunner?: QueryRunner,
): Promise<any> {
): Promise<T> {
if (InstanceChecker.isMongoEntityManager(this.manager))
throw new TypeORMError(`Queries aren't supported by MongoDB.`)

View File

@ -170,7 +170,7 @@ export class EntityManager {
/**
* Executes raw SQL query and returns raw database results.
*/
async query(query: string, parameters?: any[]): Promise<any> {
async query<T = any>(query: string, parameters?: any[]): Promise<T> {
return this.connection.query(query, parameters, this.queryRunner)
}