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

261
Views
Mongodb $min valor es mayor que $max a veces

Estoy obteniendo la fecha de la base de datos mongo y devuelve $first , $max , $min y $last , sin embargo, sucede algo muy inusual: $min es mayor que $max . Aquí está mi código:

 let Lowestdate = await ETHMongo.aggregate([ { $match: { createdAt: { $gte: new Date(last), $lte: new Date(NEW) } }, }, { $group: { _id: null, minFee_doc: { $first: "$$ROOT" }, minFee: { $min: "$one" }, firstFee: { $first: "$one" }, lastFee: { $last: "$one" }, maxFee: { $max: "$one" }, }, }, ]).then((result) => {});

¿Alguna solución? Encabezado de tabla resultados incorrectos

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

0

Parece que sus "números" se guardan como string , en la comparación de cadenas "99" > "1000000" .

Afortunadamente, puede resolver esto muy fácilmente, simplemente convierta la cadena en número usando $toInt

 { $group: { _id: null, minFee_doc: { $first: "$$ROOT" }, minFee: { $min: {$toInt: "$one"} }, firstFee: { $first: "$one" }, lastFee: { $last: "$one" }, maxFee: { $max: {$toInt: "$one"} }, }, }
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!