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

423
Visualizações
How to query on multiple filters in pymongo's find_one_and_update() method?

I am trying to use pymongo's find_one_and_update() method to update some values in mongoDB, but I need to filter based on two different conditions, and this does not seem possible.

I tried passing in a list of filters akin to [{"name": "name"}, {"date": "date}], but this did not work.

Is there no way to filter on multiple conditions with this method? How else can I achieve this?

Thanks

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I figured out that the single filter argument can be a query using boolean logic. The solution was:

{"$and":[{"name": "name"}, {"date": "date"}]}

as the filter argument.

over 4 years ago · Santiago Trujillo Relatório

0

Well for multiple filters,if you need all of them to be in effect, then its just a simple filter dictonary as below:

find_one({"name": "name"}, {"date": "date"})

However, if you need to have any of those multiple filters to be in effect, then you can use $or operator

find_one({"$or":[{"name": "name"}, {"date": "date"}]})
over 4 years ago · Santiago Trujillo Relatório
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