I have been attempting to use bluebird promises with the pg library, and even found this post but sadly I am too new of a StackOverflow user to simply comment there directly: Manually promisifying pg.connect with Bluebird
Put simply, everything I've tried with the bluebird Promisfy function after doing a cut and paste of that code doesn't pull in any of the query constructors, and maybe I'm misusing the ClientAsync function in the attempts I made, but am hoping this is a quick and easy help as everything I try results in some variation of:
Possibly unhandled TypeError: Object function (err) {
if(err) {
pool.destroy(client);
} else {
pool.release(client);
}
} has no method 'queryAsync'
I dumped the PromisfyAll function result, and sure enough queryAsync isn't present:
Relevant snippet:
Client: { [Function] Query: { [Function] super_: [Object] } },
Query:
{ [Function]
super_: { [Function: EventEmitter] listenerCount: [Function] } },
pools:
{ all: {},
Client: { [Function] Query: [Object] },
getOrCreate: [Function] },
Connection:
{ [Function]
super_: { [Function: EventEmitter] listenerCount: [Function] } },
types:
{ getTypeParser: [Function],
setTypeParser: [Function],
arrayParser: { create: [Function] } },
ClientAsync: { [Function: ClientAsync] __isPromisified__: true },
endAsync: { [Function: endAsync] __isPromisified__: true },
connectAsync: { [Function: connectAsync] __isPromisified__: true },
cancelAsync: { [Function: cancelAsync] __isPromisified__: true },
setMaxListenersAsync: { [Function: setMaxListenersAsync] __isPromisified__: true },
emitAsync: { [Function: emitAsync] __isPromisified__: true },
addListenerAsync: { [Function: addListenerAsync] __isPromisified__: true },
onAsync: { [Function: onAsync] __isPromisified__: true },
onceAsync: { [Function: onceAsync] __isPromisified__: true },
removeListenerAsync: { [Function: removeListenerAsync] __isPromisified__: true },
removeAllListenersAsync: { [Function: removeAllListenersAsync] __isPromisified__: true },
listenersAsync: { [Function: listenersAsync] __isPromisified__: true } }
It finds the relevant functions in the parse, but doesn't promisfy Query: does anyone know how I can trouble-shoot this further or the potential syntax for executing a SQL query with ClientAsync? I have attempted to add the pg query.js file in manually from the information on the Bluebird github page but to no avail.