|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 03-May-2022 | - |
| m4/ | H | 03-May-2022 | - | 4,148 | 3,849 |
| tclconfig/ | H | 03-May-2022 | - | 529 | 351 |
| tests/ | H | 03-May-2022 | - | 1,635 | 1,369 |
| COPYRIGHT | H A D | 15-Jul-2018 | 2.3 KiB | 52 | 51 |
| Makefile.in | H A D | 07-May-2019 | 16.4 KiB | 459 | 228 |
| README.md | H A D | 07-May-2019 | 4.9 KiB | 167 | 119 |
| aclocal.m4 | H A D | 07-May-2019 | 690 | 16 | 11 |
| configure | H A D | 09-May-2019 | 255.8 KiB | 9,331 | 7,387 |
| configure.ac | H A D | 05-May-2019 | 11 KiB | 356 | 106 |
| example-nx-gridfs.tcl | H A D | 24-Dec-2017 | 3.4 KiB | 126 | 45 |
| example-nx-wiki.tcl | H A D | 04-Dec-2014 | 1.2 KiB | 44 | 29 |
| example-nx-wiki0.tcl | H A D | 04-Dec-2014 | 1.2 KiB | 44 | 29 |
| mongoAPI.decls | H A D | 27-Dec-2016 | 5.4 KiB | 185 | 167 |
| mongoAPI.h | H A D | 22-Mar-2019 | 42.7 KiB | 1,013 | 834 |
| mongoAPI.nxdocindex | H A D | 04-Aug-2016 | 1.4 KiB | 31 | 30 |
| nsfmongo.c | H A D | 07-May-2019 | 57.8 KiB | 1,937 | 1,269 |
| nsfmongo.c.ast.sh | H A D | 02-May-2019 | 520 | 4 | 4 |
| nx-mongo.tcl | H A D | 07-May-2019 | 34.1 KiB | 1,028 | 716 |
| pkgIndex.add | H A D | 09-May-2019 | 82 | 2 | 1 |
| pkgIndex.add.in | H A D | 17-Mar-2015 | 90 | 2 | 1 |
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