Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

263
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda