Open andrisi opened 2 years ago
Connection has a method Connection.destroy() which should provide the required functionality
Should now be fixed, please use version 0.7.2
Closing issue for now, please reopen again if not resolved
It still says "this._conn.destroy is not a function" when calling a connection's destroy method, because it's called "destory" in the _conn object. Actually something else is broken too, as the Record's _record is null to after getting it from the Resultset. Version 0.6.2 works ok.
@andrisi I've published 0.7.3 which fixes the typo in connection - do you have a code example for the Record's _record is null to after getting it from the Resultset
?
Connectiondestroy() works ok now.
The problem with destroying recordsets is that because resultset.getRecords() uses a callback and it does not support async functions, it's sort of hard to find the moment where you'd call resultset.destroy(). I need to emit an event and pass the record to the outside to be able to use database calls for example. Could you support async event handlers for getRecords - that is waiting for completition if the result of the function is a promise? Or suggest another way?
Sorry, I actually could find a place to close the resultset - with an example where I do not need to use db operations, see:
this.z.query('prefix', query).search((err, resultset) => {
if(err)
{
console.log(err)
return
}
hits = resultset.size
if(hits > 0 && hits < 10000)
{
resultset.getRecords(0, hits, (err, records) => {
while (records && records.hasNext())
{
let record = records.next()
let marc = new Record(record.json)
marc.dumpMain()
}
event.emit('done', resultset)
})
}
else
{
event.emit('done')
}
})
let recordsetToClose = await pEvent(event, 'done')
recordsetToClose.destroy()
The one that uses async db functions does a event.emit('record', record)
for each record and then a listener does the save op asyncronously. This might make some queues big, but that's not so important with small recordsets.
So the node app doesn't exit.