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

432
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
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