Querying MongoDB - the basics

Hi,
I’ve been using Redash till now for querying SQL sources (like Data bricks) and all is great.
Lately I need to query some Mongo collections and I have trouble finding a clear spec which explains the basics.
For example this is my “hello world” query for getting the first 3 documents of a specific companyID.
How do I properly select only few fields and not all fields (as *) ? I tried $project but this doesn’t work.
Bottom line - is there a clear complete reference?

{
   "collection": "collectionName",
   "query": {
        "metadata.companyId": 9426
    },
   "limit":3
}

Welcome to the forum!

The official Redash documentation reference is here.

To select specific fields you can use the fields key:

{
   "collection": "collectionName",
   "query": {
        "metadata.companyId": 9426
    },
   "fields": ["some", "field", "names", "here"],
   "limit":3
}
1 Like