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

145
Visualizações
how can i get all the datas that have same value from mongodb?

in my database, there are two companies with same name.

[
  {
    "name": "samsung",
    "store_code": "34d"
  },
  {
    "name": "lg",
    "store_code": "333"
  },
  {
    "name": "lg",
    "store_code": "3511"
  }
]

like this..

my question is, I juse made my python function to get store information by name.

that looks like this..

async def fetch_store_by_name(store_name):
document = collection.find_one({"name":store_name})
return document

and I can only get the first lg company's information. how can I get both informations of lg company from my mongodb?

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

0

Use find instead of find_one .

https://www.w3schools.com/python/python_mongodb_find.asp

over 4 years ago · Santiago Trujillo Relatório

0

I assumed you're using pymongo, just change find_one to find method. Like this:

async def fetch_store_by_name(store_name):
  document = collection.find({"name":store_name})
  return document

Here some documentation : https://pymongo.readthedocs.io/en/stable/tutorial.html#querying-for-more-than-one-document

over 4 years ago · Santiago Trujillo Relatório

0

You can use collection.find({"name":store_name})

Reference: https://www.w3schools.com/python/python_mongodb_find.asp

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