Q: What’s the default query in Studio 3T and does it have an equivalent in MongoDB.
A: It’s a Studio 3T feature that lets you associate a query with a MongoDB collection. Simply create and save a query as the default query for a collection. Opening the collection again in the Collection Tab, will automatically load and run that saved query.
Let’s look at an example. Consider if you are only ever looking for movies which have a “Short” genre in the sample_mflix movies collection. You can set up a query that only shows you movies with that in the genre array:
Click on the Anchor icon in the top right and that sets this query as your default. The query is now associated with this particular collection. Now, let’s test if it works.
Now close the collection tab. Then reopen the collection. It will reappear with that query already loaded. The saved query includes the projection, sort, skip, and limit values. This means you can save a query that only shows the fields you want, in the order you want.
Most importantly that query is only associated with that particular collection on your Studio 3T desktop. It doesn’t affect any other collection or user. This means you can create queries that let you focus on the essential documents that you need.
Bonus default query tip
The brush next to the run button is “Clear Query”. That will clear out your current query from the current view. To clear the saved default query, call up the sub-menu on the anchor icon where you’ll find “Clear Default Query”. Finally, just in case you accidentally clear your carefully crafted query, there is a “Restore Default Query” option to bring a cleared default query back.
As you can see, it’s a very useful day-to-day feature which doesn’t have an equivalent in MongoDB.