Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-103

FindAndModify C Driver

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • 0.4
    • None
    • 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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            johellstrand Jan-Olof Hellstrand
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: