Mark As Completed Discussion

Being able to retrieve a single document is useful but often, we will want to fetch multiple documents based on some condition. For this, we typically use a query method. This is where our document database starts to shine - as the flexibility of a JSON-like structure allows us to easily query nested attributes.

For any senior engineer working in software development, you might have come across querying data when dealing with programs related to AI or finance, or any system that needs to fetch data based on specific conditions. For our document database, a basic query operation will sift through every single document it has stored, checking to see if the document matches the given condition.

Let's illustrate this with a query operation that retrieves all documents where the key customer_id is equal to 12345. See the Python code in the code section.

PYTHON
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment