From e35a5ff20084e9315e1ef8655284e41745bcdc69 Mon Sep 17 00:00:00 2001 From: Karl Lehenbauer Date: Thu, 13 Feb 2014 22:55:43 +0000 Subject: [PATCH] In the cursor "next" method, invoke mongotcl_setCursorError on error rather than mongotcl_setMongoError. You now get a CURSOR_EXHAUSTED after there are no more rows, although this is clumsy and needs more work. BUGZID: --- README.md | 11 ++++++++++- generic/cursor.c | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9570bf7..b5e3f4a 100755 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ There's a compile warning on this. It's probably coredump. Removes a document from a MongoDB server. bson is the bson query. -* $mongo cursor name +* $mongo cursor name namespace Create a cursor for this MongoDB connection. Name is the name of the object created. If name is #auto, a unique name will be automatically generated and returned. @@ -366,5 +366,14 @@ This is a little gross and is going to be simplified, but... $cursor next $cursor to_list +``` + +* Perform a complex query +```tcl + bson create query + query init start_object \$query int age 24 finish_object start_object \$orderby int name 1 finish_object finish + $cursor init $namespace + $cursor set_query $query +``` diff --git a/generic/cursor.c b/generic/cursor.c index 7620a0c..f3c282f 100644 --- a/generic/cursor.c +++ b/generic/cursor.c @@ -346,7 +346,7 @@ mongotcl_cursorObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_ case OPT_CURSOR_NEXT: { if (mongo_cursor_next (mc->cursor) != MONGO_OK) { - return mongotcl_setMongoError (interp, mc->conn); + return mongotcl_setCursorError (interp, mc->cursor); } break; }