skip to Main Content

I am trying to get all books that match my several book_ids, but instead I only get one of the books.

books =  mydb.Book.find({"book_id ": book_id})

2

Answers


  1. Chosen as BEST ANSWER

    I solved my problem,
    listBooks=[] listBooks.append(book_id)


  2. You can use $in to find all the documents that match any value in your list book_ids

    see the doc

    books =  mydb.Book.find({"book_id": {"$in": book_ids}})
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search