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

225
Views
Is in mongodb something like prepared statements in php for security?

I am just learning mongodb and have one important question. Is in mongodb something for security like its in php? In php I could use something like:

$stmt = $this->conn->prepare("UPDATE news SET shown = shown+1 WHERE newsID = :newsID");
$stmt->bindValue(":newsID", $id, PDO::PARAM_INT);
$stmt->execute();

But what in mongodb? Its weird to see inserting variables directly into mongodb insert statement like:

db.products.insertOne( { _id: 10, "item": itemName, "qty": itemQuantity } );

Thank you for your explanation!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Unless you would construct something like

db.products.insertOne( JSON.parse('{ _id: 10, "item": itemName, "qty": itemQuantity }') )

an SQL injections would be rather difficult. I guess no one does such code voluntarily.

When you run have statement like db.find({"someProperty": userInput}) and a hacker tries to pass {"$exists": true} then it will result into db.find({"someProperty": "{\"$exists\": true}"}) which should not return any result.

But as mentioned, using JSON.parse() or similar could be a security flaw.

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!