node-sqlite3
node-sqlite3 copied to clipboard
Provide complete call back to serialize/paralleize function
How do we make sure that db#serialize is completed before executing the start timer code again?. I see await/async with a promise to be the only option to fix this. Is there any better way to solve this ?. db#serialize should have provided a completed call back.
db#each has a completed call back, but other db# functions don't provide that option.
I have already pasted this in stack overflow. No solutions yet. Is it possible to provide complete call back to serialize function ?
function checkLoop()
{
//console.log("Checking for any request to process")
db.serialize(function(){
db.each('select * from prepare_updates where finished_at IS NULL',
function(err, row){
if(err === null )
{
console.log("preparing updates for " + row.id)
// Some processing
}
})
})
console.log("Starting timer again ")
if(!stop)
{
setTimeout(function(){checkLoop()},2000);
}
}
You can use a callback in the last statement inside serialize() and use it to resolve a promise or callback into your code
That is what I am doing now. It would be convenient to provide a callback.