some one can help to write following mongo shell request in using mongodb c driver ?
Hi Xiaokuai,
You can find a number of practical examples on libmongoc guides: Aggregation Framework to perform MongoDB aggregation pipeline using MongoDB C driver.
For example using the current version of the driver v1.12.0, your aggregation pipeline would look :
bson_t *pipeline;
pipeline = BCON_NEW("pipeline", "[",
"{", "$project", "{", "RECORDS",
"{", "$filter",
"{", "input", "$RECORDS",
"as", "item",
"cond", "{", "$and", "[",
"{", "$gte", "[", "$$item.TM", BCON_INT32(1215388800), "]", "}",
"{", "$lte", "[", "$$item.TM", BCON_INT32(1215734400), "]", "}",
"]", "}",
"}", "}", "}", "}", "]");
cursor = mongoc_collection_aggregate(collection, MONGOC_QUERY_NONE, pipeline, NULL, NULL);
while (mongoc_cursor_next(cursor, &doc)){
str = bson_as_canonical_extended_json(doc, NULL);
printf("%s\n", str);
bson_free(str);
}
If you have any further question, please provide:
Regards,
Wan.