mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
refactor: query methods should accept generic for return type (#9957)
* query should accept generics * Update DataSource.ts
This commit is contained in:
parent
0e56f0fcf8
commit
f5b93c14b5
@ -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.`)
|
||||
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user