Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

488
Vistas
Alternative to Mongo $where that errors out in PDI?

This criteria featuring a $where clause which uses JavaScript works fine at the command prompt, for example when enclosed in db.mycollection.find(). By that I mean it returns matching records where test field has value "true" and dateTime field which is in epoch milliseconds has value that falls within the previous day...

{$and:[{test:"true",$where: function(){return (new Date(this.dateTime + 86400000) < new Date())}}]}

...but in PDI CE 8, it throws an error com.mongodb.util.JSONParseException and points at the u in function, for example, when used as criteria in a "MongoDB input" step for deleting records.

I couldn't find the reason specifically, but I believe function (and aggregation and probably many others) cannot be used as matching criteria via PDI (nor via MongoDB Compass). This seems to be a point of general confusion on the internet about two different species of "mongo commands". Any guidance that explains that in a plain way could be very helpful to predict which is which, to prevent wasting time developing with the wrong species (maybe "Avoid anything with parentheses in criteria" is the rule?), but my main question is...

Is there an alternative mongo criteria I could use to accomplish the same goal?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda