Aggregate

Execute MongoDb aggregate over your database

When you have a complex query where you need to link more than several collections together, and when you need to calculate, aggregate, sum up, and group the data, you can write aggregate and execute it from the API.

Execute MongoDb aggregate over your database.

get

When you have complex query where you need link more than several collections together, and when you need calculate, aggregate, sum up, group the data, then you can write aggregate and execute it from the API. https://docs.codemash.io/api/database/collections/aggregate

Authorizations
Path parameters
IdstringRequired

Id of an aggregate

CollectionNamestringRequired

Collection name - unique, lowercased, collection name without whitespace. E.g., if your collection title you have entered in the CodeMash dashboard is "Business Trips" then collection name would be "business-trips".

versionstringRequired

The CodeMash API version used to fetch data from the API. If not specified, the last version will be used. E.g.: v2

Header parameters
AcceptanyRequired

Accept Header

X-CM-ClusterstringOptional

API key of your cluster. Can be passed in a header as X-CM-Cluster.

X-CM-ProjectIdstringRequired

ID of your project. Can be passed in a header as X-CM-ProjectId.

CultureCodestringOptional

Specify culture code when your response from the API should be localised. E.g.: en

Body

Dictionary<String,String>

Other propertiesstringOptional
Responses
200
Success
application/json
get
GET //{version}/db/{CollectionName}/aggregate/{id} HTTP/1.1
Host: api.codemash.io
Authorization: YOUR_API_KEY
X-CM-ProjectId: text
Content-Type: application/json
Accept: */*
Content-Length: 34

{
  "ANY_ADDITIONAL_PROPERTY": "text"
}
200

Success

{
  "response_status": {
    "error_code": "text",
    "message": "text",
    "stack_trace": "text",
    "errors": [
      {
        "error_code": "text",
        "field_name": "text",
        "message": "text",
        "meta": {
          "ANY_ADDITIONAL_PROPERTY": "text"
        }
      }
    ],
    "meta": {
      "ANY_ADDITIONAL_PROPERTY": "text"
    }
  },
  "result": "text"
}

Execute MongoDb aggregate over your database.

post

When you have complex query where you need link more than several collections together, and when you need calculate, aggregate, sum up, group the data, then you can write aggregate and execute it from the API. https://docs.codemash.io/api/database/collections/aggregate

Authorizations
Path parameters
IdstringRequired

Id of an aggregate

CollectionNamestringRequired

Collection name - unique, lowercased, collection name without whitespace. E.g., if your collection title you have entered in the CodeMash dashboard is "Business Trips" then collection name would be "business-trips".

versionstringRequired

The CodeMash API version used to fetch data from the API. If not specified, the last version will be used. E.g.: v2

Header parameters
AcceptanyRequired

Accept Header

X-CM-ClusterstringOptional

API key of your cluster. Can be passed in a header as X-CM-Cluster.

X-CM-ProjectIdstringRequired

ID of your project. Can be passed in a header as X-CM-ProjectId.

CultureCodestringOptional

Specify culture code when your response from the API should be localised. E.g.: en

Body

Dictionary<String,String>

Other propertiesstringOptional
Responses
200
Success
application/json
post
POST //{version}/db/{CollectionName}/aggregate/{id} HTTP/1.1
Host: api.codemash.io
Authorization: YOUR_API_KEY
X-CM-ProjectId: text
Content-Type: application/json
Accept: */*
Content-Length: 34

{
  "ANY_ADDITIONAL_PROPERTY": "text"
}
200

Success

{
  "response_status": {
    "error_code": "text",
    "message": "text",
    "stack_trace": "text",
    "errors": [
      {
        "error_code": "text",
        "field_name": "text",
        "message": "text",
        "meta": {
          "ANY_ADDITIONAL_PROPERTY": "text"
        }
      }
    ],
    "meta": {
      "ANY_ADDITIONAL_PROPERTY": "text"
    }
  },
  "result": "text"
}
var client = new CodeMashClient(apiKey, projectId);
var service = new CodeMashRepository<Person>(client);

var aggregateOptions = new AggregateOptions {
    Tokens = new Dictionary<string, string> { { "name", "John" } }
}

var aggregateResult = await service.AggregateAsync<PersonProjection>(
    Guid.Parse("{AGGREGATE_ID}"),
    aggregateOptions
);

Check the docs on aggregation.

Last updated

Was this helpful?