[CDRIVER-103] FindAndModify C Driver Created: 11/Nov/11  Updated: 11/Sep/19  Resolved: 23/Mar/12

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 0.4
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Jan-Olof Hellstrand Assignee: Unassigned
Resolution: Done Votes: 0
Labels: commands
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux 64 bit



 Description   

Data:
================================================================
PRIMARY> use config
switched to db config
PRIMARY> db.tpgen.find().pretty()
{
"_id" : "outque",
"creation_dt" : ISODate("2011-11-11T12:24:18.197Z"),
"description" : "Name of TPGEN outque",
"value" : "bwh"
}

CODE:
================================================================

bson cmd;
bson out =

{NULL, 0}

;

bson_init( &cmd );
bson_append_string( &cmd, "findAndModify", "tpgen" );

bson_append_start_object( &cmd, "query" );
bson_append_string( &cmd, "_id", key_p );
bson_append_finish_object( &cmd );

bson_append_start_object( &cmd, "update" );
bson_append_start_object( &cmd, "$set" );
bson_append_time_t( &cmd, "last_access_time", time( NULL ) );
bson_append_finish_object( &cmd );
bson_append_finish_object( &cmd );

bson_append_start_object( &cmd, "fields" );
bson_append_string( &cmd, "value", "" );
bson_append_finish_object( &cmd );
bson_finish( &cmd );

if( mongo_run_command( conn, "config", &cmd, &out ) == MONGO_OK )
{
bson_print( &out );
bson_iterator it;
if( bson_find( &it, &out, "value" ) )

{ strcpy( value_p, bson_iterator_string( &it ) ); printf( "Value is %s\n", value_p ); }

}

bson_print( &out) above printouts;
================================================
lastErrorObject : 3
updatedExisting : 8 true
n : 16 1
lastOp : 18 5673711064269717505
connectionId : 16 2645
err : 10 BSON_NULL
ok : 1 1.000000

value : 3
_id : 2 outque
value : 2 bwh

ok : 1 1.000000

Question: I dont understand why an ego object is returned in out bson object.



 Comments   
Comment by Kyle Banker [ 23/Nov/11 ]

Returning the lastErrorObject is the standard server behavior.

Comment by Jan-Olof Hellstrand [ 23/Nov/11 ]

Sorry, a typo. It should say :"I dont understand why an the lastErrorObject object is returned in the out bson object."

Comment by Kyle Banker [ 22/Nov/11 ]

What do you mean when you say 'ego object'?

Generated at Wed Feb 07 21:08:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.