I am trying to connect to mongodb and insert GET parameters, using G-WAN and mongodb’s C driver, i successfully connecting to mongodb, but i havent succeeded any data inserts.
I am using the code
mongo_write_concern_init(write_concern);
write_concern->w = 0;
mongo_write_concern_finish(write_concern);
bson b[1];
bson_init( b );
bson_append_new_oid( b, "_id" );
bson_append_string( b, "param1", param1);
bson_append_string( b, "param2", param2);
status = mongo_insert( conn, "mydb.mycol", b , write_concern);
bson_finish( b );
bson_destroy( b );
mongo_write_concern_destroy(write_concern);
connection is successfull, i can see it through mongod.log file;
[conn36] run command admin.$cmd { ismaster: 1 }
[conn36] command admin.$cmd command: { ismaster: 1 } ntoreturn:1 reslen:71 0ms
[conn36] end connection 127.0.0.1:50086
but nothing else, i cant get any error messages or error log, also on mongodb shell when i call last errors
> db.getLastError()
null
returns null
any idea why this happens or any solution you can advice is welcome, thank you
This call must be before mongo_insert():
Otherwise you have an unfinished BSON object here:
So the code should be