porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.42k stars 271 forks source link

Simple delete query is not working for me #687

Closed elhananjair closed 1 year ago

elhananjair commented 1 year ago

I am trying to run a delete query, I have an array that contains values to delete from the table, but it is not deleting.

let totalNum = [] //this contains an array of numbers
//e.g totalNum = [122, 322, 424, 233];

async function deleteNum(){
    try {
        totalNum.map(async num => await sql`delete from mytable.numlist where digit = ${ num } returning digit`)
    } catch (e) {
        console.log("Error Found: " + e.message)
    }
}

deleteNum().catch(e => console.log(e));

It is not deleting from the table, what am I missing here?

priyanshu-101 commented 1 year ago

@elhananjair this code is in which file?

priyanshu-101 commented 1 year ago

Please assign it to me I will solve it

elhananjair commented 1 year ago

@elhananjair this code is in which file?

it seems there was some issue with my async await implementation, it works now.