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

197
Visualizações
How to query data with and conditions in mongoose

I have a document of transactions where a transaction can be of different shops.

I want to query transactions with certain id in certain date. I have a field for date and id which is a MongoDB id, when I query using

Transaction.find({ $and: [{ date: nepali_date.day, shop_id: user.shop_id }] }).lean()

It returns data of all the transaction with the date given, I don't want that, I want the data of date 14 AND shop id "61f3c70c89e5453d271e0ea7"

but instead it returns:

{
"_id": "61f3c81a1410f50644d981b6",
"year": 2078,
"month": 9,
"date": 14,
"title": "Krus",
"amount": 60,
"type": "income",
"author": "Eclipsu",
"authorID": "61ef7e9565a4a88874937e96",
"shopID": "61f3c70c89e5453d271e0ea7",
"edited": false
},
{
"_id": "61f3c89ce0ea4276ddba693f",
"year": 2078,
"month": 9,
"date": 14,
"title": "RAJ",
"amount": 50,
"type": "income",
"author": "Eclipsu",
"authorID": "61ef7e9565a4a88874937e96",
"shopID": "61ef7ea165a4a88874937e9d",
"edited": false
}```
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