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

262
Views
insert into NedB boolean value without quotation marks

I have a NedB database which I'm trying to insert some new data into that I retrieve from HTML form, this is my function to insert new.

addEntry(name,desc,ingred,allergy,cat,aval,price){
        var entry = {
            Name: name,
            Description: desc,
            Ingerdients: ingred.split(','),
            Allergy: allergy.split(','),
            Category: cat,
            Availability: aval,
            price: price
        }
        this.db.insert(entry, function(err,doc) {
            if(err)
            {
                console.log("error inserting document",subject);
            }
            else{
                console.log('Meal Added Successfully');
            }
        })
    }

My problem is that the Availability is a boolean value, yet it's added in the database with quotation marks. For example: 'true' instead of true and 'false' instead of false, how can I fix this?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Assuming that the parameter aval is a string, you could convert it to a boolean:

var entry = {
  Name: name,
  Description: desc,
  Ingerdients: ingred.split(','),
  Allergy: allergy.split(','),
  Category: cat,
  Availability: aval === "true",
  price: price
}

But I am surprised that the database accepts a string value where it should expect a boolean. Doesn't it give you an error message?

over 4 years ago · Santiago Trujillo 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!