Skip to main content

Querying with code

Obviously, you'll want to access the data in your collections using your programming language of choice. The syntax is very similar to what you've just seen.

const query = { title: /godfather/i };
const options = { projection: { title: 1, runtime: 1}, sort: { year: -1 } };
const movies = collection.find(query, options).toArray();