2
votes

I'm using Azure CosmosDB Data explorer (Azure Portal -> Azure Cosmos DB -> Data Explorer). There're only JSON query string {"foo": "bar"}. How can I select only specific field or use aggregate command there? e.g., document structure:

{
  "age": 30,
  "city": "Oslo"
}

and I would to select only:

{
  "city": "Oslo"
}
1

1 Answers

2
votes

How can I select only specific field or use aggregate command there?

To select only specific field, please refer to below command in mongo shell on portal:

get all data from city field with _id

db.coll.find({}, {city:1})

get all data from city field without _id

db.coll.find({}, {city:1,_id:0})

Test:

enter image description here

As for the aggregation function,cosmos db mongo api only supports partial of the all mongo aggregation functions,please refer to this document to check the supported features.