brianc / node-pg-cursor

Query cursor extension for node-postgres
78 stars 30 forks source link

Result of client.query(Cursor) is not an EventEmitter #24

Closed sberan closed 7 years ago

sberan commented 7 years ago

According to the API docs, the result from any of the client.query(...) variants is always a query object.

However, when using a Cursor, the result has none of the events prescribed by the API. In fact, it is not even an event emitter. This is not a purely academic issue as querying with a cursor causes an error in newrelic instrumentation which is built around this spec.

Do you agree that the query(Cursor) method should conform to the PG API spec by returning an EventEmitter? If so would you accept a PR to add event emitter behavior and the emit the required Query events from the Cursor object?

brianc commented 7 years ago

I think it'd be sweet to have the Cursor emit events - I don't think it'd cause any harm at all. Good idea! And it's a backwards compatible change too which is even extra beautiful. 👏 I'd definitely accept a pull request.

sberan commented 7 years ago

See #25 :bowtie: