Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
How to delete multiple id from req.params in sequelize?

how to accept req.params that contain multiple id ? I want to search and delete the multiple id

here's my code :

const id = req.params;
    
    const masterFunders = await masterFunder.findOne({
      where: {
        id: ids
      }
    })

    if (!masterFunders) {
      return res.API.error(RESPONSE_MESSAGE.file_not_found, 400)
    }

    if (masterFunders.createdAt.getTime() > new Date().getTime() - (1000 * 60 * 60 * 24 * 10 * 3)) {
      return res.API.error(RESPONSE_MESSAGE.cannot_delete_file, 400)
    }
    
    await masterFunder.destroy({
      where: { id: ids }
    });

    return res.API.success(RESPONSE_MESSAGE.success, 200)
  } catch (error) {
    console.log(error)
    return res.API.error(error.message)

it's error

{
    "status": false,
    "message": "Invalid value {\n  id: '[de7cc75d-4925-4a8d-869c-9072c7310fc9, b9da8552-e3f9-4628-a5a2-9709399b20dc]'\n}",
    "meta": {}
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

"ids" seems to be a string that contains an array in JSON format, not a JavaScript array.

So you need to do: ids = JSON.parse(ids); to convert the string to a JavaScript array :)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!