1,747
社区成员
发帖
与我相关
我的任务
分享
BOOL RSmppMongoDb::_db_res_query()
{
const bson_t *doc;
bson_error_t error;
const char *collection_name = "cac_sms_sent_pool";
bson_t *query;
char *str;
mongoc_collection_t *collection;
mongoc_cursor_t *cursor;
query = bson_new ();
BSON_APPEND_UTF8 (query, "apply_state", "0");
collection = mongoc_client_get_collection (m_pClient, "cac", collection_name);
cursor = mongoc_collection_find (collection, MONGOC_QUERY_NONE, 0, 0, 0, \
query, NULL,/* Fields, NULL for all. */ NULL); /* Read Prefs, NULL for default */
while (mongoc_cursor_next (cursor, &doc))
{
str = bson_as_json (doc, NULL);
fprintf (stdout, "%s\n", str);
bson_free (str);
}
if (mongoc_cursor_error (cursor, &error)) {
fprintf (stderr, "Cursor Failure: %s\n", error.message);
return EXIT_FAILURE;
}
bson_destroy (query);
mongoc_cursor_destroy (cursor);
mongoc_collection_destroy (collection);
}