|
driver-php here's an example which will work once CDRIVER-1844 is done:
mongoc_server_description_t *sd;
|
uint32_t server_id;
|
bson_t *cmd;
|
bson_t *opts;
|
bson_t reply;
|
bool r;
|
mongoc_cursor_t *cmd_cursor;
|
|
sd = mongoc_topology_select (client->topology, MONGOC_SS_READ,
|
NULL, &error);
|
|
server_id = mongoc_server_description_id (sd);
|
cmd = BCON_NEW ("aggregate", BCON_UTF8 ("my_collection"),
|
"pipeline", "[", "]");
|
opts = BCON_NEW ("serverId", BCON_INT64 (server_id),
|
"cursor", "{", "}");
|
r = mongoc_client_read_command_with_opts (client, "test", cmd,
|
NULL /* prefs */, opts, &reply,
|
&error);
|
|
if (!r) {
|
printf ("error: %s\n", error.message);
|
return;
|
}
|
|
cmd_cursor = mongoc_cursor_new_from_command_reply (client, &reply, server_id);
|
|