Skip to content

Commit

Permalink
Add "delete" methods for bson, cursor and mongo objects. Doc updates …
Browse files Browse the repository at this point in the history
…as pointed out by Andreas Kupries.

BUGZID:
  • Loading branch information
lehenbauer committed Feb 20, 2014
1 parent 8909a63 commit 0fca829
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ MongoTcl, a Tcl C extension providing a Tcl interface to the MongoDB database

MongoTcl provides a Tcl interface to the MongoDB C API.

FA Note
License
---
If pursued far enough, when this is solid enough it will be open sourced.

Open source under the permissive Berkeley copyright, see file LICENSE

Requirements
---
Requires the MongoDB C driver to be installed. Currently builds against version 0.8.1.

Building
---
Expand Down Expand Up @@ -45,7 +50,7 @@ More about bson at http://bsonspec.org/

MongoDB use of BSON at http://docs.mongodb.org/meta-driver/latest/legacy/bson/

MongoTcl has a bson object and the bson creator is invoked to create bson objects, siilarly to iTcl objects
MongoTcl has a bson object and the bson creator is invoked to create bson objects, simiarly to iTcl objects

```tcl
::mongo::bson create
Expand Down Expand Up @@ -173,6 +178,10 @@ Enumerate bson object as an array of key-value pairs. Embedded bson arrays and

if typeArrayName is specified, for each key of the key-value pairs, an element is inserted into typeArray for the same key with the value being the name of the bson datatype such as int, double, string, oid, etc.

* $bson delete

Delete the bson object.

* $bson print

Print is for debugging only, it sort of shows you what's in the bson object.
Expand Down Expand Up @@ -289,6 +298,14 @@ Drop a collection.

Drop a database.

* $mongo delete

Delete the mongo object. Can also be done by doing a

```tcl
rename $mongo ""
```

Cursor Methods
---

Expand Down Expand Up @@ -354,6 +371,9 @@ Allow reads even if a shard is down.

Set what fields are returned. fieldList is a list of field names with 1 or 0. 1 says to include the field, 0 says to exclude it. The fieldList is sticky for future queries. This may change. See http://docs.mongodb.org/manual/tutorial/project-fields-from-query-results/ for how the 1/0 thing works.

* $cursor delete

Delete the cursor object.

Search
---
Expand Down Expand Up @@ -394,6 +414,11 @@ Example

When you're done using the bson object, destroy it by doing a

```tcl
$bson delete
```
or, if you prefer...

```tcl
rename $bson ""
```
Expand Down
10 changes: 9 additions & 1 deletion generic/bson.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ mongotcl_bsonObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_Ob
"to_array",
"array_set",
"finish",
"delete",
"print",
NULL
};
Expand All @@ -858,6 +859,7 @@ mongotcl_bsonObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_Ob
OPT_TO_ARRAY,
OPT_ARRAY_SET,
OPT_FINISH,
OPT_DELETE,
OPT_PRINT
};

Expand Down Expand Up @@ -1238,7 +1240,13 @@ mongotcl_bsonObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_Ob
return mongotcl_setBsonError (interp, bd->bson);
}
break;
}
}

case OPT_DELETE: {
Tcl_DeleteCommandFromToken (interp, bd->cmdToken);
break;
}


case OPT_PRINT: {
bson_print (bd->bson);
Expand Down
9 changes: 8 additions & 1 deletion generic/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ mongotcl_cursorObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_
"set_limit",
"set_options",
"data",
"delete",
NULL
};

Expand All @@ -231,7 +232,8 @@ mongotcl_cursorObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_
OPT_CURSOR_SET_SKIP,
OPT_CURSOR_SET_LIMIT,
OPT_CURSOR_SET_OPTIONS,
OPT_CURSOR_DATA
OPT_CURSOR_DATA,
OPT_CURSOR_DELETE
};

/* basic validation of command line arguments */
Expand Down Expand Up @@ -442,6 +444,11 @@ mongotcl_cursorObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_
}
break;
}

case OPT_CURSOR_DELETE: {
Tcl_DeleteCommandFromToken (interp, mc->cmdToken);
break;
}
}

return TCL_OK;
Expand Down
7 changes: 7 additions & 0 deletions generic/mongotcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ mongotcl_mongoObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_O
"add_user",
"drop_collection",
"drop_db",
"delete",
NULL
};

Expand Down Expand Up @@ -233,6 +234,7 @@ mongotcl_mongoObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_O
OPT_CMD_ADD_USER,
OPT_CMD_DROP_COLLECTION,
OPT_CMD_DROP_DB,
OPT_DELETE
};

/* basic validation of command line arguments */
Expand Down Expand Up @@ -965,6 +967,11 @@ mongotcl_mongoObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_O
}
break;
}

case OPT_DELETE: {
Tcl_DeleteCommandFromToken (interp, md->cmdToken);
break;
}
}
return TCL_OK;
}
Expand Down

0 comments on commit 0fca829

Please sign in to comment.