Index: TODO =================================================================== diff -u -r90abb70405a475dea0eee8e780bc43eaa699ea1f -r40086b195a1a43958f7e99ce6f66a8ab2ae6337c --- TODO (.../TODO) (revision 90abb70405a475dea0eee8e780bc43eaa699ea1f) +++ TODO (.../TODO) (revision 40086b195a1a43958f7e99ce6f66a8ab2ae6337c) @@ -3038,6 +3038,7 @@ - library/mongodb: * updated to current interface in git HEAD * added flag timeout to mongo::connect + * added new index uptions "-sparse" and "-background" TODO: - maybe use (position == -1) instead of (objectparameter == false) to save common vars Index: library/mongodb/mongoAPI.decls =================================================================== diff -u -r90abb70405a475dea0eee8e780bc43eaa699ea1f -r40086b195a1a43958f7e99ce6f66a8ab2ae6337c --- library/mongodb/mongoAPI.decls (.../mongoAPI.decls) (revision 90abb70405a475dea0eee8e780bc43eaa699ea1f) +++ library/mongodb/mongoAPI.decls (.../mongoAPI.decls) (revision 40086b195a1a43958f7e99ce6f66a8ab2ae6337c) @@ -33,7 +33,9 @@ {-argName "conn" -required 1 -type mongo_connection} {-argName "namespace" -required 1} {-argName "attributes" -required 1 -type tclobj} + {-argName "-background" -required 0 -nrargs 0} {-argName "-dropdups" -required 0 -nrargs 0} + {-argName "-sparse" -required 0 -nrargs 0} {-argName "-unique" -required 0 -nrargs 0} } Index: library/mongodb/mongoAPI.h =================================================================== diff -u -r90abb70405a475dea0eee8e780bc43eaa699ea1f -r40086b195a1a43958f7e99ce6f66a8ab2ae6337c --- library/mongodb/mongoAPI.h (.../mongoAPI.h) (revision 90abb70405a475dea0eee8e780bc43eaa699ea1f) +++ library/mongodb/mongoAPI.h (.../mongoAPI.h) (revision 40086b195a1a43958f7e99ce6f66a8ab2ae6337c) @@ -40,7 +40,7 @@ static int NsfMongoGridFileOpen(Tcl_Interp *interp, gridfs *fsPtr, CONST char *filename); static int NsfMongoGridFileRead(Tcl_Interp *interp, gridfile *filePtr, int size); static int NsfMongoGridFileSeek(Tcl_Interp *interp, gridfile *filePtr, int offset); -static int NsfMongoIndex(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *attributes, int withDropdups, int withUnique); +static int NsfMongoIndex(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *attributes, int withBackground, int withDropdups, int withSparse, int withUnique); static int NsfMongoInsert(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *values); static int NsfMongoQuery(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *query, Tcl_Obj *withAtts, int withLimit, int withSkip); static int NsfMongoRemove(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *condition); @@ -362,11 +362,13 @@ mongo_connection *connPtr = (mongo_connection *)pc.clientData[0]; CONST char *namespace = (CONST char *)pc.clientData[1]; Tcl_Obj *attributes = (Tcl_Obj *)pc.clientData[2]; - int withDropdups = (int )PTR2INT(pc.clientData[3]); - int withUnique = (int )PTR2INT(pc.clientData[4]); + int withBackground = (int )PTR2INT(pc.clientData[3]); + int withDropdups = (int )PTR2INT(pc.clientData[4]); + int withSparse = (int )PTR2INT(pc.clientData[5]); + int withUnique = (int )PTR2INT(pc.clientData[6]); assert(pc.status == 0); - return NsfMongoIndex(interp, connPtr, namespace, attributes, withDropdups, withUnique); + return NsfMongoIndex(interp, connPtr, namespace, attributes, withBackground, withDropdups, withSparse, withUnique); } } @@ -517,11 +519,13 @@ {"file", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"gridfile",NULL,NULL,NULL,NULL,NULL}, {"offset", NSF_ARG_REQUIRED, 1, Nsf_ConvertToInt32, NULL,NULL,"int32",NULL,NULL,NULL,NULL,NULL}} }, -{"::mongo::index", NsfMongoIndexStub, 5, { +{"::mongo::index", NsfMongoIndexStub, 7, { {"conn", NSF_ARG_REQUIRED, 1, Nsf_ConvertToPointer, NULL,NULL,"mongo_connection",NULL,NULL,NULL,NULL,NULL}, {"namespace", NSF_ARG_REQUIRED, 1, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"attributes", NSF_ARG_REQUIRED, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, + {"-background", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"-dropdups", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, + {"-sparse", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"-unique", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, {"::mongo::insert", NsfMongoInsertStub, 3, { Index: library/mongodb/nsfmongo.c =================================================================== diff -u -r90abb70405a475dea0eee8e780bc43eaa699ea1f -r40086b195a1a43958f7e99ce6f66a8ab2ae6337c --- library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision 90abb70405a475dea0eee8e780bc43eaa699ea1f) +++ library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision 40086b195a1a43958f7e99ce6f66a8ab2ae6337c) @@ -628,13 +628,21 @@ {-argName "conn" -required 1 -type mongo_connection} {-argName "namespace" -required 1} {-argName "attributes" -required 1 -type tclobj} + {-argName "-background" -required 0 -nrargs 0} {-argName "-dropdups" -required 0 -nrargs 0} + {-argName "-sparse" -required 0 -nrargs 0} {-argName "-unique" -required 0 -nrargs 0} } */ static int -NsfMongoIndex(Tcl_Interp *interp, mongo_connection *connPtr, CONST char *namespace, Tcl_Obj *attributesObj, - int withDropdups, int withUnique) { +NsfMongoIndex(Tcl_Interp *interp, + mongo_connection *connPtr, + CONST char *namespace, + Tcl_Obj *attributesObj, + int withBackground, + int withDropdups, + int withSparse, + int withUnique) { bson_bool_t success; int objc, result, options = 0; Tcl_Obj **objv; @@ -645,8 +653,10 @@ return NsfPrintError(interp, "%s: must contain a multiple of 3 elements", ObjStr(attributesObj)); } BsonAppendObjv(interp, keys, objc, objv); - if (withDropdups) {options |= MONGO_INDEX_DROP_DUPS;} - if (withUnique) {options |= MONGO_INDEX_UNIQUE;} + if (withBackground) {options |= MONGO_INDEX_BACKGROUND;} + if (withDropdups) {options |= MONGO_INDEX_DROP_DUPS;} + if (withSparse) {options |= MONGO_INDEX_SPARSE;} + if (withUnique) {options |= MONGO_INDEX_UNIQUE;} success = mongo_create_index(connPtr, namespace, keys, options, out); bson_destroy(keys);