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

142
Views
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 answers
Answer question

0

Use find instead of find_one .

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

over 4 years ago · Santiago Trujillo Report

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 Report

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