Reputation: 11
db.serialize(()=>{ const rightjoinpromise=new Promise((resolve,reject)=>{ db.all( 'select temp_data.colour,temp_data.size,temp_data.price,temp_data.quantity,temp_data.barcode,shoe.shoe_id from shoe right join temp_data on shoe.article_name=temp_data.article_name', (err, rows) => { console.log('in db.all at start') if (err) { dialog.showMessageBox(mainWindow, { message: `or or here Internal Server Error, ${err.message}`, buttons: [] }) reject(err) } else { console.log('in db.all else at start') if (!rows.length) { console.log('No result got from right join of TEMP_DATA and SHOE tables') } else { // new Promise((resolveee, rejecttt) => { // db.serialize(()=>{ console.log('in db.all before foreach at start') console.log("rows: ",rows) rightjoinrows=rows console.log('rows array copied into rightjoinrows',rightjoinrows) resolve(rows) // resolveee() // }).finally(()=>{ // }) } } } ) }) rightjoinpromise .then((rows)=>{ rows.forEach((row) => { ........... }) })
I've tried using promises, callbacks. but nothing is working The db.close() at end of db.serialize() is getting executed before db.run() and causing error I want that result set of db.all() be used in db.run()
Upvotes: 1
Views: 17