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

285
Views
No se puede consultar la fecha de MongoDB (Mlab): tan simple pero no se puede resolver

Después de semanas de esfuerzo, todavía tengo problemas para consultar el campo de fecha movie_datetime que tiene la estructura a continuación de Mlab usando NodeJS.

 "movie_datetime": { "$date": "2017-01-03T16:00:00.000Z" }, "session_id": 31268

ingrese la descripción de la imagen aquí

Intenté lo siguiente

 db.mycollection.find({ "movie_datetime" : {"gte" : { "$date" : "2013-10-01T00:00:00.000Z"}} }) db.mycollection.find({ "movie_datetime" : {"$gte": new Date("2013-10-01T00:00:00.000Z")} }) db.mycollection.find({ "movie_datetime" : {"$gte": Date("2013-10-01T00:00:00.000Z")} }) db.mycollection.find({ "movie_datetime" : {"$gte": ISODate("2013-10-01T00:00:00.000Z")} })

Agradezco cualquier ayuda.

Códigos nodeJS actuales :

** Probé variaciones de comillas simples y dobles y omití .toISOString

 var dateTime = '{"movie_datetime":{"$gte" : "'+new Date("2017-01-03T16:00:00.000Z").toISOString()+'"}}'; var dateTimeJson =JSON.parse(dateTimeVar); db.mycollection.find(dateTimeJson); Result for print dateTime {"movie_datetime":{"$gte" : "2017-01-03T16:00:00.000Z"}} Result for print dateTimeJson { movie_datetime: { '$gte': '2017-01-03T16:00:00.000Z' } }

Versión de nodo 6.6.0

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Si está utilizando la interfaz mlab, en realidad es así:

 { "createdAt": { "$gt": { "$date": "2017-11-08T20:05:45.866Z" } } }
over 4 years ago · Santiago Trujillo Report

0

Creo que esto debería hacerlo.

 db.myCollection.find({ 'movie_datetime.$date': { '$gte': new Date('2013-10-01T00:00:00.000Z') } });

editar: la imagen que publicaste y el JSON que proporcionaste son diferentes. Para la foto sería -

 db.myCollection.find({ 'date.$date': { '$gte': new Date('2013-10-01T00:00:00.000Z') } });
over 4 years ago · Santiago Trujillo Report

0

revisa los documentos

Las fechas se insertan en el formato que se indica a continuación.

 {"myDate": {"$date": "2010-07-20T23:23:50Z"}}
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!