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})
CodePudding user response:
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}})
CodePudding user response:
I solved my problem,
listBooks=[]
listBooks.append(book_id)