7
print_coll_info (bson *info)
13
gboolean capped = FALSE;
17
c = bson_find (info, "name");
18
bson_cursor_get_string (c, &name);
19
bson_cursor_find (c, "options");
21
bson_cursor_get_document (c, &options);
23
printf ("Options for %s:\n", name);
28
c = bson_find (options, "capped");
29
bson_cursor_get_boolean (c, &capped);
32
c = bson_find (options, "size");
33
bson_cursor_get_int64 (c, &size);
36
c = bson_find (options, "max");
37
bson_cursor_get_int64 (c, &max);
42
printf ("\tCapped: %s\n", (capped) ? "yes" : "no");
44
printf ("\tSize : %lu\n", size);
46
printf ("\tMax : %lu\n", max);
53
mongo_sync_connection *conn;
55
conn = mongo_sync_connect ("localhost", 27017, FALSE);
58
fprintf (stderr, "Connection failed: %s\n", strerror (errno));
62
mongo_sync_cmd_create (conn, "lmc", "cmd_create", MONGO_COLLECTION_DEFAULTS);
63
print_coll_info (mongo_sync_cmd_exists (conn, "lmc", "cmd_create"));
65
mongo_sync_cmd_create (conn, "lmc", "cmd_create_capped",
66
MONGO_COLLECTION_CAPPED, 655360);
67
print_coll_info (mongo_sync_cmd_exists (conn, "lmc", "cmd_create_capped"));
69
mongo_sync_cmd_create (conn, "lmc", "cmd_create_capped_max",
70
MONGO_COLLECTION_CAPPED | MONGO_COLLECTION_CAPPED_MAX,
72
print_coll_info (mongo_sync_cmd_exists (conn, "lmc",
73
"cmd_create_capped_max"));
75
mongo_sync_cmd_create (conn, "lmc", "cmd_create_sized",
76
MONGO_COLLECTION_SIZED, 655360);
77
print_coll_info (mongo_sync_cmd_exists (conn, "lmc", "cmd_create_sized"));
79
mongo_sync_disconnect (conn);