Skip to content

Instantly share code, notes, and snippets.

@sindbach
sindbach / insertSubDocumentExample.c
Created September 25, 2015 00:17
A simple C example to insert a sub document in MongoDB.
#include <bson.h>
#include <mongoc.h>
#include <stdio.h>
int main (int argc, char *argv[])
{
mongoc_client_t *client;
mongoc_collection_t *collection;
mongoc_cursor_t *cursor;
bson_error_t error;
@sindbach
sindbach / uncapCollectionExample.cpp
Created September 24, 2015 23:13
A simple cpp example to uncap a capped collection in MongoDB. This version is using the legacy mongo-cxx-driver https://github.com/mongodb/mongo-cxx-driver.
#include "mongo/client/dbclient.h"
int main() {
/* Initialize Driver */
mongo::Status status = mongo::client::initialize();
if (!status.isOK()){
std::cout<< "Failed to initialize driver." << std::endl;
return EXIT_FAILURE;
}