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

134
Visualizações
Change the value of an object to Long

I want the value of the object to be not a double type but a Long type.

client.db("customDB").collection("chart").insertMany( [{"chart": data.chart}]...


  "chart" : [ 
    {
        "x" : 1635017640000.0, ----->   1635017640000 (LONG NUMBER)
        "y" : [ 
            0.13715, 
            0.13715001, 
            0.13714999, 
            0.13715
        ]
    }
 
]  

Thank you :)

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

parseInt(1635017640000.0) would be the way to go :)

No need to import anything.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt

Remember to google the issue - in javascript any floating point number is called float and any number without comma is an int or rather "integer"

about 4 years ago · Juan Pablo Isaza Relatório

0

You can use Math.floor to convert to an integer and strip the fraction.

The Math.floor() function returns the largest integer less than or equal to a given number.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor

{
  x: Math.floor(123.456)
}

Results in

{
  x: 123
}
about 4 years ago · Juan Pablo Isaza 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