Skip to content

Commit b14c511

Browse files
committed
CDRIVER-1522 define constants for "find" opts
1 parent c715397 commit b14c511

File tree

3 files changed

+151
-92
lines changed

3 files changed

+151
-92
lines changed

src/mongoc/mongoc-cursor-cursorid.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ _mongoc_cursor_prepare_getmore_command (mongoc_cursor_t *cursor,
193193

194194
/* See find, getMore, and killCursors Spec for batchSize rules */
195195
if (batch_size) {
196-
bson_append_int64 (command, "batchSize", 9,
196+
bson_append_int64 (command, BATCH_SIZE, BATCH_SIZE_LEN,
197197
abs (_mongoc_n_return (cursor)));
198198
}
199199

@@ -204,14 +204,15 @@ _mongoc_cursor_prepare_getmore_command (mongoc_cursor_t *cursor,
204204
option maxAwaitTimeMS. If no maxAwaitTimeMS is specified, the driver
205205
SHOULD not set maxTimeMS on the getMore command."
206206
*/
207-
await_data = _mongoc_cursor_get_opt_bool (cursor, "tailable") &&
208-
_mongoc_cursor_get_opt_bool (cursor, "awaitData");
207+
await_data = _mongoc_cursor_get_opt_bool (cursor, TAILABLE) &&
208+
_mongoc_cursor_get_opt_bool (cursor, AWAIT_DATA);
209209

210210

211211
if (await_data) {
212212
max_await_time_ms = (int32_t) mongoc_cursor_get_max_await_time_ms (cursor);
213213
if (max_await_time_ms) {
214-
bson_append_int32 (command, "maxTimeMS", 9, max_await_time_ms);
214+
bson_append_int32 (command, MAX_TIME_MS, MAX_TIME_MS_LEN,
215+
max_await_time_ms);
215216
}
216217
}
217218

src/mongoc/mongoc-cursor-private.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,62 @@ struct _mongoc_cursor_interface_t
4747
mongoc_host_list_t *host);
4848
};
4949

50+
#define ALLOW_PARTIAL_RESULTS "allowPartialResults"
51+
#define ALLOW_PARTIAL_RESULTS_LEN 19
52+
#define AWAIT_DATA "awaitData"
53+
#define AWAIT_DATA_LEN 9
54+
#define BATCH_SIZE "batchSize"
55+
#define BATCH_SIZE_LEN 9
56+
#define COMMENT "comment"
57+
#define COMMENT_LEN 7
58+
#define EXHAUST "exhaust"
59+
#define EXHAUST_LEN 7
60+
#define FILTER "filter"
61+
#define FILTER_LEN 6
62+
#define FIND "find"
63+
#define FIND_LEN 4
64+
#define HINT "hint"
65+
#define HINT_LEN 4
66+
#define LIMIT "limit"
67+
#define LIMIT_LEN 5
68+
#define MAX "max"
69+
#define MAX_LEN 3
70+
#define MAX_AWAIT_TIME_MS "maxAwaitTimeMS"
71+
#define MAX_AWAIT_TIME_MS_LEN 14
72+
#define MAX_SCAN "maxScan"
73+
#define MAX_SCAN_LEN 7
74+
#define MAX_TIME_MS "maxTimeMS"
75+
#define MAX_TIME_MS_LEN 9
76+
#define MIN "min"
77+
#define MIN_LEN 3
78+
#define NO_CURSOR_TIMEOUT "noCursorTimeout"
79+
#define NO_CURSOR_TIMEOUT_LEN 15
80+
#define OPLOG_REPLAY "oplogReplay"
81+
#define OPLOG_REPLAY_LEN 11
82+
#define ORDERBY "orderby"
83+
#define ORDERBY_LEN 7
84+
#define PROJECTION "projection"
85+
#define PROJECTION_LEN 10
86+
#define QUERY "query"
87+
#define QUERY_LEN 5
88+
#define READ_CONCERN "readConcern"
89+
#define READ_CONCERN_LEN 11
90+
#define RETURN_KEY "returnKey"
91+
#define RETURN_KEY_LEN 9
92+
#define SHOW_DISK_LOC "showDiskLoc"
93+
#define SHOW_DISK_LOC_LEN 11
94+
#define SHOW_RECORD_ID "showRecordId"
95+
#define SHOW_RECORD_ID_LEN 12
96+
#define SINGLE_BATCH "singleBatch"
97+
#define SINGLE_BATCH_LEN 11
98+
#define SKIP "skip"
99+
#define SKIP_LEN 4
100+
#define SNAPSHOT "snapshot"
101+
#define SNAPSHOT_LEN 8
102+
#define SORT "sort"
103+
#define SORT_LEN 4
104+
#define TAILABLE "tailable"
105+
#define TAILABLE_LEN 8
50106

51107
struct _mongoc_cursor_t
52108
{

0 commit comments

Comments
 (0)