Closed yuyaryshev closed 5 years ago
Here https://node-postgres.com/guides/upgrading#client-query-submittable- is described event emmiter functionality.
But in typescript is this:
export class Query extends events.EventEmitter { // <<<<<<<<< Does not extends Submittable on(event: "row", listener: (row: any, result?: ResultBuilder) => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "end", listener: (result: ResultBuilder) => void): this; } .... // <<<<<<<<< There is no overload accepting "Query" and returning "Query" query<T extends Submittable>(queryStream: T): T; query(queryConfig: QueryArrayConfig, values?: any[]): Promise<QueryArrayResult>; query(queryConfig: QueryConfig): Promise<QueryResult>; query(queryTextOrConfig: string | QueryConfig, values?: any[]): Promise<QueryResult>; query(queryConfig: QueryArrayConfig, callback: (err: Error, result: QueryArrayResult) => void): Query; query(queryTextOrConfig: string | QueryConfig, callback: (err: Error, result: QueryResult) => void): Query; query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): Query;
Also, here: https://node-postgres.com/features/queries event emmiter functionality it's not mensioned, which is sad.
So can "event emmiter functionality" actually be used? Is it stable? How should it be used?
You would create a query object, passing it to the query<T extends Submittable>(queryStream: T): T overload and getting the same query object back. See client.query with a Submittable.
query<T extends Submittable>(queryStream: T): T
Submittable
Here https://node-postgres.com/guides/upgrading#client-query-submittable- is described event emmiter functionality.
But in typescript is this:
Also, here: https://node-postgres.com/features/queries event emmiter functionality it's not mensioned, which is sad.
So can "event emmiter functionality" actually be used? Is it stable? How should it be used?