Closed
Description
await sql.begin((tx:any)=>{
return Promise.all([
tx`select 1 as cursor, x from generate_series(1,4) as x`.cursor(async (row: any[])=>{
console.log('cursor1' , JSON.stringify(row));
await new Promise(resolve=>setTimeout(resolve, 2000));
}),
tx`select 2 as cursor, x from generate_series(101,104) as x`.cursor(async (row: any[])=>{
console.log('cursor2' , JSON.stringify(row));
await new Promise(resolve=>setTimeout(resolve, 1000));
})
]);
});
This code returns unexpected console output:
cursor1 {"cursor":1,"x":1}
cursor1 {"cursor":2,"x":101}
cursor1 {"cursor":2,"x":102}
cursor1 {"cursor":2,"x":103}
cursor1 {"cursor":2,"x":104}
is it possible to support simultaneous reading for multiple cursors in single transaction?