Index: library/mongodb/README =================================================================== diff -u -re5d5a53bdd5482a7173ac81cff141906ac23cf32 -rcef3de5c4f65e767d0c66389bacc77bc3c2e5a68 --- library/mongodb/README (.../README) (revision e5d5a53bdd5482a7173ac81cff141906ac23cf32) +++ library/mongodb/README (.../README) (revision cef3de5c4f65e767d0c66389bacc77bc3c2e5a68) @@ -4,26 +4,44 @@ Ingredients: https://github.com/mongodb/mongo https://github.com/mongodb/mongo-c-driver + https://github.com/mongodb/libbson The current version is tested with - MongoDB v2.4.9 -- mongodb-c-driver v0.8.1 +- mongodb-c-driver 0.90.1 +- libbson 0.4.3 Compile or obtain mongodb (the database). + +Compile or obtain libbson (binary json library) + + cd /usr/local/src + git clone https://github.com/mongodb/libbson + cd libbson + sh autogen.sh + make + sudo make install + Compile or obtain the mongo-c-driver (client interface) + + cd /usr/local/src git clone https://github.com/mongodb/mongo-c-driver cd mongo-c-driver - git checkout v0.8.1 + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig make - make install + sudo make install -Assume, Tcl is under /usr/local/ns/lib and the source of the -mongo-c-driver is under /usr/local/src/mongo-c-driver/, -then configure the nsf interface via the following -command from nsf*/library/mongodb/ +Assume the following installation directories + - Tcl: /usr/local/ns/lib/ + - mongo-c-driver: /usr/local/src/mongo-c-driver/ + - libbson: /usr/local/src/libbson +configure the mongodb nsf interface via the following +command in the directory nsf*/library/mongodb/ - ./configure --with-tcl=/usr/local/ns/lib --with-nsf=../../ \ - --with-mongodb=/usr/local/src/mongo-c-driver/src/,/usr/local/src/mongo-c-driver + ./configure --with-tcl=/usr/local/ns/lib/ --with-nsf=../../ \ + --with-mongoc=/usr/local/src/mongo-c-driver/mongoc/,/usr/local/src/mongo-c-driver/.libs \ + --with-bson=/usr/local/src/libbson/bson,/usr/local/src/libbson/.libs \ + --enable-threads --enable-symbols --prefix=/usr/local/ns In order to run the sample script, @@ -51,97 +69,33 @@ This example script is using the higher level object oriented interface for nx (nx::mongo). -* Further sample-scripts: + After running this script, you should could + check the content in MongoDB: - ./nxsh library/mongodb/example-nx-bi.tcl - ./nxsh library/mongodb/example-nx-reference-one.tcl - ./nxsh library/mongodb/example-nx-reference-many.tcl - ./nxsh library/mongodb/example-nsf-gridfs.tcl + % mongo + MongoDB shell version: 2.4.9 + connecting to: test + > use tutorial + switched to db tutorial + > db.persons.find(); + { "_id" : ObjectId("530c6e4649686ad16e261f81"), "name" : "Gustaf", "projects" : "nsf", "age" : 53 } + { "_id" : ObjectId("530c6e4649686ad16e261f82"), "name" : "Stefan", "projects" : "nsf" } + { "_id" : ObjectId("530c6e4649686ad16e261f83"), "name" : "Victor", "a" : [ "x", "y" ], "age" : 31 } + { "_id" : ObjectId("530c6e4649686ad16e261f84"), "name" : "Joe", "projects" : "abc", "age" : 23, "classes" : [ DBRef("courses", ObjectId("100000000000000000000000")) ] } + { "_id" : ObjectId("530c6e4649686ad16e261f85"), "name" : "Franz", "info" : { "x" : 203, "y" : 102 }, "age" : 29, "projects" : "gtat" } + { "_id" : ObjectId("530c6e4649686ad16e261f86"), "name" : "Selim", "ts" : Timestamp(1302945037, 1), "d" : ISODate("2011-04-16T09:53:39.279Z") } + > -After running the scripts, you should see output like the one below. +* Further sample-scripts: - % /usr/local/bin/mongo - MongoDB shell version: 2.4.4-pre- - connecting to: test - > use tutorial - switched to db tutorial - > db.persons.find(); + ./nxsh library/mongodb/tests/nx-bi.test + ./nxsh library/mongodb/tests/nx-reference-one.test + ./nxsh library/mongodb/tests/nx-reference-many.test + ./nxsh library/mongodb/tests/nx-rep.test + ./nxsh library/mongodb/tests/nx-serialize.test + ./nxsh library/mongodb/tests/nsf-gridfs.test + -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 -=============================================================== - - -~/src/nsf-2.0.0% ./nxsh library/mongodb/example-nx-mongo.tcl - -Query: {$query} object {name string Gustaf} -_id oid 4d9c224135018d4500000000 name string Gustaf age integer 53 projects array {0 string nsf} - -Query: {$query} object {name string Gustaf} -_id oid 4d9c224135018d4500000000 name string Gustaf age integer 55 projects array {0 string xowiki 1 string nsf} - -Project members of nsf: -Query: {$query} object {projects string nsf} -_id oid 4d9c224135018d4500000000 name string Gustaf age integer 55 projects array {0 string xowiki 1 string nsf} -_id oid 4d9c224135018d4500000001 name string Stefan projects array {0 string nsf} - ::nsf::__#5: Gustaf - ::nsf::__#6: Stefan - -All Persons sorted by name (ascending): -Query: {$query} object {} {$orderby} object {name int 1} -_id oid 4d9c224135018d4500000003 name string Franz age integer 29 projects array {0 string gtat 1 string annobackend 2 string abc} -_id oid 4d9c224135018d4500000000 name string Gustaf age integer 55 projects array {0 string xowiki 1 string nsf} -_id oid 4d9c224135018d4500000002 name string Joe age integer 23 projects array {0 string abc} -_id oid 4d9c224135018d4500000001 name string Stefan projects array {0 string nsf} - ::nsf::__#7: Franz - ::nsf::__#8: Gustaf - ::nsf::__#9: Joe - ::nsf::__#A: Stefan - -Members of Projects != 'abc' nsf sorted by name desc and age: -Query: {$query} object {projects object {{$ne} string abc}} {$orderby} object {name int -1 age int 1} -_id oid 4d9c224135018d4500000001 name string Stefan projects array {0 string nsf} -_id oid 4d9c224135018d4500000000 name string Gustaf age integer 55 projects array {0 string xowiki 1 string nsf} - ::nsf::__#B: Stefan - ::nsf::__#C: Gustaf - -Find persons age > 30: -Query: {$query} object {age object {{$gt} integer 30}} -_id oid 4d9c224135018d4500000000 name string Gustaf age integer 55 projects array {0 string xowiki 1 string nsf} - ::nsf::__#D: Gustaf - -Find oldies: -Query: {$query} object {age object {{$gt} integer 30}} -_id oid 4d9c224135018d4500000000 name string Gustaf age integer 55 projects array {0 string xowiki 1 string nsf} - ::nsf::__#E: Gustaf -Nsfmongo Exit