Aggregate
Overview of aggregation API
get
https://api.codemash.io
/:version/db/:collectionName/aggregate/:id
Aggregate
.NET
Node
PHP
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
);
โ€‹
use Codemash\CodemashClient;
use Codemash\CodemashDb;
โ€‹
class CodemashService
{
protected CodemashDb $codemashDb;
protected string $collectionName = '{YOUR_COLLECTION_NAME}';
โ€‹
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
โ€‹
$client = new CodemashClient($secretKey, $projectId);
$this->codemashDb = new CodemashDb($client);
}
โ€‹
public function aggregate()
{
$responseData = $this->codemashDb->getAggregate([
'collectionName' => 'employees',
'id' => '{AGGREGATE_ID}',
]);
}
}
Check the docs on aggregation.
Last modified 1yr ago
Copy link