Skip to content

Commit a8617f6

Browse files
committed
CDRIVER-4010 document let option for aggregate command
1 parent e37552d commit a8617f6

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

build/generate-opts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ def __init__(self, items, **defaults):
320320
bypass_option,
321321
collation_option,
322322
server_option,
323-
('batchSize', {'type': 'int32_t', 'help': 'An ``int32`` representing number of documents requested to be returned on each call to :symbol:`mongoc_cursor_next`', 'check_set': True})
323+
('batchSize', {'type': 'int32_t', 'help': 'An ``int32`` representing number of documents requested to be returned on each call to :symbol:`mongoc_cursor_next`', 'check_set': True}),
324+
('let', {'type': 'document', 'help': 'A BSON document consisting of any number of parameter names, each followed by definitions of constants in the MQL Aggregate Expression language'})
324325
])),
325326

326327
('mongoc_find_and_modify_appended_opts_t', Struct([

src/libmongoc/doc/includes/aggregate-opts.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
* ``collation``: Configure textual comparisons. See :ref:`Setting Collation Order <setting_collation_order>`, and `the MongoDB Manual entry on Collation <https://docs.mongodb.com/manual/reference/collation/>`_. Collation requires MongoDB 3.2 or later, otherwise an error is returned.
1313
* ``serverId``: To target a specific server, include an int32 "serverId" field. Obtain the id by calling :symbol:`mongoc_client_select_server`, then :symbol:`mongoc_server_description_id` on its return value.
1414
* ``batchSize``: An ``int32`` representing number of documents requested to be returned on each call to :symbol:`mongoc_cursor_next`
15+
* ``let``: A BSON document consisting of any number of parameter names, each followed by definitions of constants in the MQL Aggregate Expression language

src/libmongoc/src/mongoc/mongoc-opts-private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ typedef struct _mongoc_aggregate_opts_t {
185185
uint32_t serverId;
186186
int32_t batchSize;
187187
bool batchSize_is_set;
188+
bson_t let;
188189
bson_t extra;
189190
} mongoc_aggregate_opts_t;
190191

src/libmongoc/src/mongoc/mongoc-opts.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,7 @@ _mongoc_aggregate_opts_parse (
18851885
mongoc_aggregate_opts->serverId = 0;
18861886
mongoc_aggregate_opts->batchSize = 0;
18871887
mongoc_aggregate_opts->batchSize_is_set = false;
1888+
bson_init (&mongoc_aggregate_opts->let);
18881889
bson_init (&mongoc_aggregate_opts->extra);
18891890

18901891
if (!opts) {
@@ -1967,6 +1968,15 @@ _mongoc_aggregate_opts_parse (
19671968

19681969
mongoc_aggregate_opts->batchSize_is_set = true;
19691970
}
1971+
else if (!strcmp (bson_iter_key (&iter), "let")) {
1972+
if (!_mongoc_convert_document (
1973+
client,
1974+
&iter,
1975+
&mongoc_aggregate_opts->let,
1976+
error)) {
1977+
return false;
1978+
}
1979+
}
19701980
else {
19711981
/* unrecognized values are copied to "extra" */
19721982
if (!BSON_APPEND_VALUE (
@@ -1993,6 +2003,7 @@ _mongoc_aggregate_opts_cleanup (mongoc_aggregate_opts_t *mongoc_aggregate_opts)
19932003
mongoc_write_concern_destroy (mongoc_aggregate_opts->writeConcern);
19942004
}
19952005
bson_destroy (&mongoc_aggregate_opts->collation);
2006+
bson_destroy (&mongoc_aggregate_opts->let);
19962007
bson_destroy (&mongoc_aggregate_opts->extra);
19972008
}
19982009

0 commit comments

Comments
 (0)