Interface between mongoDB and the Next Scripting Framework Ingredients: https://github.com/mongodb/mongo https://github.com/mongodb/mongo-c-driver Compile or obtain mongodb (the database). Compile or obtain the mongo-c-driver (client interface) Assume, tcl is under /usr/local/ns/lib and the mongo-c-driver is under /usr/local/src/mongo-c-driver/, then configre the nsf interface via ./configure --with-tcl=/usr/local/ns/lib --with-nsf=../../ \ --with-mongo=/usr/local/src/mongo-c-driver/src/,/usr/local/src/mongo-c-driver I had to add MONGO_HAVE_STDINT to the EXTRA_FLAGS on MacOS X EXTRA_CFLAGS = @PKG_CFLAGS@ -DMONGO_HAVE_STDINT TODO: remove the hardcoded define flag in Makefile.in In order to run the sample script, * first start the mongdb (mongod) * go to your nsf source directory * make sure, the c-driver libraries are on the library path export DYLD_LIBRARY_PATH=/usr/local/src/mongo-c-driver/:`pwd` * run ./nxsh library/mongodb/example-nsf-mongo.tcl The script has a few insert, query and delete statements, some of these are commented out. After running the script, you should see output like the following -gustaf neumann =============================================================== ~/src/nsf-2.0.0% ./nxsh library/mongodb/example-nsf-mongo.tcl /usr/local/src/tcl8.5.9/unix/tclsh Inserting a few tuples Create an index on name (ascending) Full content _id oid 4d9b0d56e7b0887e00000000 name string Joe projects string abc age integer 23 _id oid 4d9b0d56e7b0887e00000001 name string Gustaf projects string nsf age integer 53 _id oid 4d9b0d56e7b0887e00000002 name string Stefan projects string nsf _id oid 4d9b0d56e7b0887e00000003 name string Franz info object {x integer 203 y integer 102} age integer 29 _id oid 4d9b0d56e7b0887e00000004 name string Victor a array {0 string x 1 string y} age integer 31 Project members of nsf sorted by name _id oid 4d9b0d56e7b0887e00000001 name string Gustaf projects string nsf age integer 53 _id oid 4d9b0d56e7b0887e00000002 name string Stefan projects string nsf Age > 30 _id oid 4d9b0d56e7b0887e00000001 name string Gustaf projects string nsf age integer 53 _id oid 4d9b0d56e7b0887e00000004 name string Victor a array {0 string x 1 string y} age integer 31 Array 'a' contains 'x' _id oid 4d9b0d56e7b0887e00000004 name string Victor a array {0 string x 1 string y} age integer 31 Embedded object has some value (info.y > 100) _id oid 4d9b0d56e7b0887e00000003 name string Franz info object {x integer 203 y integer 102} age integer 29 Nsfmongo Exit