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

90
Views
Consulta compleja de mangosta

Usando mangosta. El esquema se parece a esto:

 { "name" : String, "start" : Date, "stop" : Date }

Lo que estoy tratando de hacer es crear una consulta, eso ("Y"):

  1. "nombre" == valor
  2. "inicio" - no existe O "inicio" valor gte
  3. "detener" - no existe O "detener" valor lte

Por otro lado, start y stop se pueden pasar, o no pasar (cualquiera de ellos).

Todos mis intentos durante un tiempo terminaron con algún tipo de error de Mongo :) Así que pido ayuda.

Saludos.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Su lógica de consulta AND se puede expresar en cualquiera de las dos formas:

Operación AND implícita :

 Model.find({ "name": name, "start": { "$or": [ { "$exists": false }, { "$gte": start } ] }, "stop": { "$or": [ { "$exists": false }, { "$gte": stop } ] } }).exec(callback);

Operación AND explícita:

 Model.find({ "$and": [ { "name": name }, { "start": { "$or": [ { "$exists": false }, { "$gte": start } ] } }, { "stop": { "$or": [ { "$exists": false }, { "$gte": stop } ] } } ] }).exec(callback);
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!