• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

m4/H03-May-2022-4,1483,849

tclconfig/H03-May-2022-529351

tests/H03-May-2022-1,6351,369

COPYRIGHTH A D15-Jul-20182.3 KiB5251

Makefile.inH A D07-May-201916.4 KiB459228

README.mdH A D07-May-20194.9 KiB167119

aclocal.m4H A D07-May-2019690 1611

configureH A D09-May-2019255.8 KiB9,3317,387

configure.acH A D05-May-201911 KiB356106

example-nx-gridfs.tclH A D24-Dec-20173.4 KiB12645

example-nx-wiki.tclH A D04-Dec-20141.2 KiB4429

example-nx-wiki0.tclH A D04-Dec-20141.2 KiB4429

mongoAPI.declsH A D27-Dec-20165.4 KiB185167

mongoAPI.hH A D22-Mar-201942.7 KiB1,013834

mongoAPI.nxdocindexH A D04-Aug-20161.4 KiB3130

nsfmongo.cH A D07-May-201957.8 KiB1,9371,269

nsfmongo.c.ast.shH A D02-May-2019520 44

nx-mongo.tclH A D07-May-201934.1 KiB1,028716

pkgIndex.addH A D09-May-201982 21

pkgIndex.add.inH A D17-Mar-201590 21

README.md

1
2
3# Interface between MongoDB and the Next Scripting Framework #
4
5This is an interface between MongoDB based on NSF (Next Scripting
6Framework)
7
8This implementation provides a low-level interface based on tagged elements
9to force / preserve the datatypes of MongoDB when converting into Tcl.
10
11This code serves as well as an example how to use the source code generator
12of NSF.  The example shows how to use the source code generator from NSF to
13generate a C interface.
14
15-gustaf neumann    March 27, 2011
16-stefan sobernig     May 6,      2019
17
18
19## Ingredients: ##
20
21  https://github.com/mongodb/mongo
22  https://github.com/mongodb/mongo-c-driver
23
24The current version of the NSF mongo binding is 2.2 and was
25tested with
26- Tcl 8.5, 8.6 and 8.7
27- MongoDB 4.0.9 (released April 16, 2019)
28- mongodb-c-driver 1.14.0 (released February 22, 2019)
29- libbson 1.14.0 (released February 22, 2019)
30
31Follow the following steps to get MongoDB up and running
32and to compile the MongoDB driver for NX.
33
34
35## Obtain MongoDB and Mongo-C-Driver: ##
36
37- Compile or obtain MongoDB (the database).
38
39- Compile or obtain the mongo-c-driver (client interface)
40
41````
42      cd /usr/local/src
43      wget https://github.com/mongodb/mongo-c-driver/releases/download/1.12.0/mongo-c-driver-1.12.0.tar.gz
44      tar zxvf  mongo-c-driver-1.12.0.tar.gz
45      rm -rf mongo-c-driver
46      ln -sf mongo-c-driver-1.12.0 mongo-c-driver
47      cd mongo-c-driver
48      cmake .
49      make
50      sudo make install
51````
52
53  Alternatively, one can get the newest version from git
54
55````
56      cd /usr/local/src
57      git clone https://github.com/mongodb/mongo-c-driver
58      cd mongo-c-driver
59      cmake .
60      make
61      sudo make install
62````
63
64  If you experience errors during autogen on Debian, you might have to
65      apt-get install libtool
66
67  If configure complains about not finding bson, you might have to do
68      export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
69
70  Note: Version 1.5.1 of the c-driver leads on macOS to a crash on
71  exit, when configured SASL support (from mac ports) and the flag
72  "--disable-automatic-init-and-cleanup" is missing.
73
74
75## Compiling the MongoDB NSF Binding: ##
76
77Assume the following installation directories
78
79  - Tcl:             /usr/local/ns/lib/
80  - mongo-c-driver: /usr/local/src/mongo-c-driver/
81
82Configure the MongoDB NSF interface via the following
83command in the directory nsf*/library/mongodb/
84
85You will probably have to adjust the paths.
86
87````
88   ./configure --with-tcl=/usr/local/ns/lib/ --prefix=/usr/local/ns --with-nsf=../../ \
89               --with-mongoc=/usr/local/include/libmongoc-1.0/,/usr/local/lib/ \
90               --with-bson=/usr/local/include/libbson-1.0,/usr/local/lib/ \
91	       --enable-threads --enable-symbols
92````
93
94In order to run the NSF sample script, perform the following steps
95
96	* first start the mongodb (e.g. mongod)
97	* go to your NSF source directory
98	* make sure, the c-driver libraries are on the library path
99      (assuming the c-driver was installed in /usr/local/lib)
100
101Linux:
102
103````
104    export LD_LIBRARY_PATH=/usr/local/lib:`pwd`
105````
106
107
108macOS:
109
110````
111    export DYLD_LIBRARY_PATH=/usr/local/lib:`pwd`
112````
113
114  * run
115
116````
117    ./nxsh library/mongodb/tests/nsf-mongo.test
118````
119
120    The script tests the low-level interface (nsf::mongo) and the
121    high-level one (nx::mongo), with each exercising a
122    few insert, query and delete statements.
123
124    After running this script, you should check the content using the
125    MongoDB shell:
126
127````
128    % mongo
129    MongoDB shell version: v4.0.9
130    connecting to: test
131    > use tutorial
132    switched to db tutorial
133    >  db.persons.find();
134   { "_id" : ObjectId("530c6e4649686ad16e261f81"), "name" : "Gustaf", "projects" : "nsf", "age" : 53 }
135   { "_id" : ObjectId("530c6e4649686ad16e261f82"), "name" : "Stefan", "projects" : "nsf" }
136   { "_id" : ObjectId("530c6e4649686ad16e261f83"), "name" : "Victor", "a" : [  "x",  "y" ], "age" : 31 }
137   { "_id" : ObjectId("530c6e4649686ad16e261f84"), "name" : "Joe", "projects" : "abc", "age" : 23, "classes" : [  DBRef("courses", ObjectId("100000000000000000000000")) ] }
138   { "_id" : ObjectId("530c6e4649686ad16e261f85"), "name" : "Franz", "info" : { "x" : 203, "y" : 102 }, "age" : 29, "projects" : "gtat" }
139   { "_id" : ObjectId("530c6e4649686ad16e261f86"), "name" : "Selim", "ts" : Timestamp(1302945037, 1), "d" : ISODate("2011-04-16T09:53:39.279Z") }
140   > quit()
141````
142
143## Testing the object oriented mapping between NX and MongoDB: ##
144
145Test the basic mapping and the OO query methods:
146
147````
148    ./nxsh library/mongodb/tests/nx-mongo.test
149````
150
151Show the classical Business Informer example in NX:
152
153````
154    ./nxsh library/mongodb/tests/nx-bi.test
155````
156
157Further test scripts for reference handling, serialization and
158MongoDB GridFS.
159
160````
161    ./nxsh library/mongodb/tests/nx-reference-one.test
162    ./nxsh library/mongodb/tests/nx-reference-many.test
163    ./nxsh library/mongodb/tests/nx-rep.test
164    ./nxsh library/mongodb/tests/nx-serialize.test
165    ./nxsh library/mongodb/tests/nsf-gridfs.test
166````
167