Index: library/mongodb/nsfmongo.c =================================================================== diff -u -re3e8f375df1313380cd13a6cb97028569f99d729 -r4dccd3ff7bcf142a60a2c56454411613ec50077e --- library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision e3e8f375df1313380cd13a6cb97028569f99d729) +++ library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision 4dccd3ff7bcf142a60a2c56454411613ec50077e) @@ -646,7 +646,7 @@ static int NsfMongoRunCmd(Tcl_Interp *interp, int withNocomplain, mongoc_client_t *clientPtr, CONST char *db, Tcl_Obj *cmdObj) { - bson_t cmd, *cmdPtr = &cmd, out, *outPtr = &out; + bson_t cmd, *cmdPtr = &cmd, reply, *replyPtr = &reply; mongoc_read_prefs_t *readPrefsPtr = NULL; /* TODO: not used */ bson_error_t bsonError; int result, objc; @@ -659,14 +659,17 @@ BsonAppendObjv(interp, cmdPtr, objc, objv); /*mongo_clear_errors( connPtr );*/ - result = mongoc_client_command_simple( clientPtr, db, cmdPtr, readPrefsPtr, outPtr, &bsonError); + result = mongoc_client_command_simple( clientPtr, db, cmdPtr, readPrefsPtr, replyPtr, &bsonError); bson_destroy( cmdPtr ); if (withNocomplain == 0 && result == 0) { - return NsfPrintError(interp, "mongo::run: command '%s' returned error: %s", ObjStr(cmdObj), bsonError.message); + return NsfPrintError(interp, "mongo::run: command '%s' returned error: %s", + ObjStr(cmdObj), bsonError.message); } - Tcl_SetObjResult(interp, Tcl_NewIntObj(result)); + Tcl_SetObjResult(interp, BsonToList(interp, replyPtr, 0)); + bson_destroy(replyPtr); + return TCL_OK; } Index: library/mongodb/tests/nsf-mongo.test =================================================================== diff -u -r6ad766595b0095a72fb7b3a1d6d34960a013b464 -r4dccd3ff7bcf142a60a2c56454411613ec50077e --- library/mongodb/tests/nsf-mongo.test (.../nsf-mongo.test) (revision 6ad766595b0095a72fb7b3a1d6d34960a013b464) +++ library/mongodb/tests/nsf-mongo.test (.../nsf-mongo.test) (revision 4dccd3ff7bcf142a60a2c56454411613ec50077e) @@ -44,7 +44,7 @@ create string persons capped bool 1 size int32 100000 - }} 1 + }} "ok double 1.0" ? {set mongoColl [::mongo::collection::open $mongoConn tutorial persons]} "mongoc_collection_t:0" puts "Collection: $mongoColl" @@ -92,6 +92,15 @@ [list \$query document {projects string nsf} \$orderby document {name int 1}]] } 2 + +package req nx::mongo +nx::mongo::Class create C + +set result [::mongo::run $mongoConn tutorial {distinct string persons key string name}] + +puts stderr "\nDistinct Persons: [C bson pp $result]" + + puts stderr "\nProject members of nsf sorted by name" ? { set r [lindex [::mongo::collection::query $mongoColl \ @@ -179,8 +188,6 @@ ? {expr [llength $stats] > 0} 1 if {[llength $stats] % 3 == 0} { - package req nx::mongo - nx::mongo::Class create C puts [C bson pp $stats] }