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

486
Visualizações
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 à 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