Index: library/mongodb/example-nx-bi.tcl =================================================================== diff -u -N -r04b17cf850af721f6ad1760dece06ef78b11da83 -ra77464d1f7a06117c621560ec519dc4d387ed5df --- library/mongodb/example-nx-bi.tcl (.../example-nx-bi.tcl) (revision 04b17cf850af721f6ad1760dece06ef78b11da83) +++ library/mongodb/example-nx-bi.tcl (.../example-nx-bi.tcl) (revision a77464d1f7a06117c621560ec519dc4d387ed5df) @@ -35,7 +35,7 @@ # Make sure, we start always from scratch, so remove everything from # the collection. -nx::mongo::db remove tutorial.postings {} +nx::mongo::db drop collection postings ###################################################################### # Create the application classes based on the "Business Insider" data Index: library/mongodb/example-nx-mongo.tcl =================================================================== diff -u -N -r5f281c1ff709a771d08362ee9593dcbe76ebbb2b -ra77464d1f7a06117c621560ec519dc4d387ed5df --- library/mongodb/example-nx-mongo.tcl (.../example-nx-mongo.tcl) (revision 5f281c1ff709a771d08362ee9593dcbe76ebbb2b) +++ library/mongodb/example-nx-mongo.tcl (.../example-nx-mongo.tcl) (revision a77464d1f7a06117c621560ec519dc4d387ed5df) @@ -12,10 +12,13 @@ ::nx::mongo::db connect -db "tutorial" # Make sure, we start always from scratch + nx::mongo::db remove tutorial.persons {} +if {[::mongo::count [::nx::mongo::db eval {set :mongoConn}] tutorial.persons {}] > 0} { + # when we create a capped colletion, we have to use "drop collection" to get rid of it. + nx::mongo::db drop collection persons +} -::mongo::run [::nx::mongo::db eval {set :mongoConn}] tutorial {drop string persons} - # # Create the application class "Person" # Index: library/mongodb/example-nx-reference-many.tcl =================================================================== diff -u -N -rc9ef41c49f482a38e89f7cffc54cabf909710425 -ra77464d1f7a06117c621560ec519dc4d387ed5df --- library/mongodb/example-nx-reference-many.tcl (.../example-nx-reference-many.tcl) (revision c9ef41c49f482a38e89f7cffc54cabf909710425) +++ library/mongodb/example-nx-reference-many.tcl (.../example-nx-reference-many.tcl) (revision a77464d1f7a06117c621560ec519dc4d387ed5df) @@ -11,8 +11,8 @@ ::nx::mongo::db connect -db "tutorial" # Make sure, we start always from scratch -nx::mongo::db remove tutorial.groups {} -nx::mongo::db remove tutorial.members {} +nx::mongo::db drop collection groups +nx::mongo::db drop collection members ###################################################################### # The first approach to implement references simply as multivalued Index: library/mongodb/example-nx-reference-one.tcl =================================================================== diff -u -N -rc9ef41c49f482a38e89f7cffc54cabf909710425 -ra77464d1f7a06117c621560ec519dc4d387ed5df --- library/mongodb/example-nx-reference-one.tcl (.../example-nx-reference-one.tcl) (revision c9ef41c49f482a38e89f7cffc54cabf909710425) +++ library/mongodb/example-nx-reference-one.tcl (.../example-nx-reference-one.tcl) (revision a77464d1f7a06117c621560ec519dc4d387ed5df) @@ -12,9 +12,10 @@ ::nx::mongo::db connect -db "tutorial" # Make sure, we start always from scratch -nx::mongo::db remove tutorial.users {} -nx::mongo::db remove tutorial.posts {} +nx::mongo::db drop collection users +nx::mongo::db drop collection posts + ###################################################################### # The first approach to implement references simply as an property. # This is just feasible in cases, where the user has just a name and Index: library/mongodb/nsfmongo.c =================================================================== diff -u -N -r04b17cf850af721f6ad1760dece06ef78b11da83 -ra77464d1f7a06117c621560ec519dc4d387ed5df --- library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision 04b17cf850af721f6ad1760dece06ef78b11da83) +++ library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision a77464d1f7a06117c621560ec519dc4d387ed5df) @@ -774,7 +774,7 @@ */ static int NsfMongoRemove(Tcl_Interp *interp, mongo *connPtr, CONST char *namespace, Tcl_Obj *conditionObj) { - int objc, result; + int objc, result, status; Tcl_Obj **objv; bson query[1]; @@ -785,8 +785,10 @@ BsonAppendObjv(interp, query, objc, objv); /* for the time being, no write_concern (last arg of mongo_remove()) */ - mongo_remove(connPtr, namespace, query, NULL); + status = mongo_remove(connPtr, namespace, query, NULL); + Tcl_SetObjResult(interp, Tcl_NewIntObj(status == MONGO_OK)); + bson_destroy(query); return TCL_OK; } @@ -971,12 +973,12 @@ static int NsfMongoGridFSRemoveFile(Tcl_Interp *interp, gridfs *gridfsPtr, CONST char *filename) { - int result; + int status; /* the current interfaces does not return a status ! */ - result = gridfs_remove_filename(gridfsPtr, filename); + status = gridfs_remove_filename(gridfsPtr, filename); - Tcl_SetObjResult(interp, Tcl_NewIntObj(result == MONGO_OK)); + Tcl_SetObjResult(interp, Tcl_NewIntObj(status == MONGO_OK)); return TCL_OK; } Index: library/mongodb/nx-mongo.tcl =================================================================== diff -u -N -r5f281c1ff709a771d08362ee9593dcbe76ebbb2b -ra77464d1f7a06117c621560ec519dc4d387ed5df --- library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision 5f281c1ff709a771d08362ee9593dcbe76ebbb2b) +++ library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision a77464d1f7a06117c621560ec519dc4d387ed5df) @@ -5,7 +5,7 @@ # package require nx package require nsf::mongo -package provide nx::mongo 0.2 +package provide nx::mongo 0.3 # todo: how to handle multiple connections; currently we have a single, global connection # todo: all references are currently auto-fetched. make this optional @@ -32,6 +32,7 @@ :public object method remove {args} {::mongo::remove ${:mongoConn} {*}$args} :public object method query {args} {::mongo::query ${:mongoConn} {*}$args} :public object method update {args} {::mongo::update ${:mongoConn} {*}$args} + :public object method "drop collection" {name} {::mongo::run ${:mongoConn} ${:db} [list drop string $name]} } #######################################################################