Querying the Database

Let's learn how to add a Spring Data query and write custom queries.

So far, we’ve both stored and retrieved data from MongoDB, but the process we’ve used isn’t the most optimal.

Looking things up by id isn’t ideal. After all, in a real-world e-commerce site, we can’t list our entire inventory and wait for the customer to select the item that way.

We need customers to enter criteria into a search box. Using the input, query the items collection. Let’s write a custom query.

Introduction to query derivation

Here’s what our search query interface looks like:

Get hands-on with 1200+ tech skills courses.