mongodb 2.1.0-alpha → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +574 -429
- package/Makefile +2 -5
- package/README.md +108 -15
- package/conf.json +17 -13
- package/index.js +13 -2
- package/lib/admin.js +113 -47
- package/lib/aggregation_cursor.js +56 -28
- package/lib/apm.js +608 -0
- package/lib/bulk/common.js +7 -7
- package/lib/bulk/ordered.js +56 -17
- package/lib/bulk/unordered.js +52 -14
- package/lib/collection.js +671 -212
- package/lib/command_cursor.js +60 -32
- package/lib/cursor.js +313 -115
- package/lib/db.js +264 -105
- package/lib/gridfs/chunk.js +26 -29
- package/lib/gridfs/grid_store.js +150 -64
- package/lib/gridfs-stream/download.js +310 -0
- package/lib/gridfs-stream/index.js +335 -0
- package/lib/gridfs-stream/upload.js +450 -0
- package/lib/metadata.js +64 -0
- package/lib/mongo_client.js +69 -39
- package/lib/mongos.js +65 -20
- package/lib/replset.js +69 -34
- package/lib/server.js +35 -1
- package/lib/topology_base.js +22 -10
- package/lib/url_parser.js +111 -13
- package/lib/utils.js +9 -8
- package/mongolabs.js +427 -0
- package/package.json +8 -6
- package/t.js +68 -51
- package/test.js +12 -0
- package/test_boot/boot.sh +3 -0
- package/test_boot/ca.pem +49 -0
- package/test_boot/client.pem +48 -0
- package/test_boot/client_password.pem +51 -0
- package/test_boot/connect.js +29 -0
- package/test_boot/data/WiredTiger +2 -0
- package/test_boot/data/WiredTiger.lock +1 -0
- package/test_boot/data/WiredTiger.turtle +6 -0
- package/test_boot/data/WiredTiger.wt +0 -0
- package/test_boot/data/WiredTigerLAS.wt +0 -0
- package/test_boot/data/_mdb_catalog.wt +0 -0
- package/test_boot/data/collection-0-757073248613337118.wt +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-44-37Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-45-15Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-46-31Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-47-25Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-49-07Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-50-41Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-50-53Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-52-31Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-54-53Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-55-09Z-00000 +0 -0
- package/test_boot/data/diagnostic.data/metrics.2015-10-07T14-55-38Z-00000 +0 -0
- package/test_boot/data/index-1-757073248613337118.wt +0 -0
- package/test_boot/data/mongod.lock +0 -0
- package/test_boot/data/sizeStorer.wt +0 -0
- package/test_boot/data/storage.bson +0 -0
- package/test_boot/server_password.pem +51 -0
- package/.travis.yml +0 -10
- package/t1.js +0 -59
- package/wercker.yml +0 -19
package/Makefile
CHANGED
|
@@ -2,13 +2,10 @@ NODE = node
|
|
|
2
2
|
NPM = npm
|
|
3
3
|
JSDOC = jsdoc
|
|
4
4
|
name = all
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
generate_docs:
|
|
7
7
|
# cp -R ./HISTORY.md ./docs/content/meta/release-notes.md
|
|
8
|
-
|
|
9
|
-
more ./HISTORY.md >> ./docs/content/meta/release-notes.md
|
|
10
|
-
pandoc docs/layouts/partials/welcome.md -o docs/layouts/partials/welcome.html
|
|
11
|
-
hugo -s docs/ -d ../public
|
|
8
|
+
hugo -s docs/reference -d ../../public
|
|
12
9
|
$(JSDOC) -c conf.json -t docs/jsdoc-template/ -d ./public/api
|
|
13
10
|
cp -R ./public/api/scripts ./public/.
|
|
14
11
|
cp -R ./public/api/styles ./public/.
|
package/README.md
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
# Description
|
|
8
8
|
|
|
9
|
-
The MongoDB driver is the high level part of the 2.
|
|
9
|
+
The MongoDB driver is the high level part of the 2.1 or higher MongoDB driver and is meant for end users.
|
|
10
10
|
|
|
11
11
|
## MongoDB Node.JS Driver
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
| what | where |
|
|
14
14
|
|---------------|------------------------------------------------|
|
|
15
15
|
| documentation | http://mongodb.github.io/node-mongodb-native/ |
|
|
16
|
-
| api-doc | http://mongodb.github.io/node-mongodb-native/ |
|
|
16
|
+
| api-doc | http://mongodb.github.io/node-mongodb-native/2.1/api/ |
|
|
17
17
|
| source | https://github.com/mongodb/node-mongodb-native |
|
|
18
18
|
| mongodb | http://www.mongodb.org/ |
|
|
19
19
|
|
|
@@ -41,9 +41,100 @@ Core Server (i.e. SERVER) project are **public**.
|
|
|
41
41
|
|
|
42
42
|
http://jira.mongodb.org/browse/NODE
|
|
43
43
|
|
|
44
|
+
# Installation
|
|
45
|
+
|
|
46
|
+
The recommended way to get started using the Node.js 2.0 driver is by using the `NPM` (Node Package Manager) to install the dependency in your project.
|
|
47
|
+
|
|
48
|
+
## MongoDB Driver
|
|
49
|
+
|
|
50
|
+
Given that you have created your own project using `npm init` we install the mongodb driver and it's dependencies by executing the following `NPM` command.
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
npm install mongodb --save
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This will download the MongoDB driver and add a dependency entry in your `package.json` file.
|
|
57
|
+
|
|
58
|
+
## Troubleshooting
|
|
59
|
+
|
|
60
|
+
The MongoDB driver depends on several other packages. These are.
|
|
61
|
+
|
|
62
|
+
* mongodb-core
|
|
63
|
+
* bson
|
|
64
|
+
* kerberos
|
|
65
|
+
* node-gyp
|
|
66
|
+
|
|
67
|
+
The `kerberos` package is a C++ extension that requires a build environment to be installed on your system. You must be able to build node.js itself to be able to compile and install the `kerberos` module. Furthermore the `kerberos` module requires the MIT Kerberos package to correctly compile on UNIX operating systems. Consult your UNIX operation system package manager what libraries to install.
|
|
68
|
+
|
|
69
|
+
{{% note class="important" %}}
|
|
70
|
+
Windows already contains the SSPI API used for Kerberos authentication. However you will need to install a full compiler tool chain using visual studio C++ to correctly install the kerberos extension.
|
|
71
|
+
{{% /note %}}
|
|
72
|
+
|
|
73
|
+
### Diagnosing on UNIX
|
|
74
|
+
|
|
75
|
+
If you don’t have the build essentials it won’t build. In the case of linux you will need gcc and g++, node.js with all the headers and python. The easiest way to figure out what’s missing is by trying to build the kerberos project. You can do this by performing the following steps.
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
git clone https://github.com/christkv/kerberos.git
|
|
79
|
+
cd kerberos
|
|
80
|
+
npm install
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If all the steps complete you have the right toolchain installed. If you get node-gyp not found you need to install it globally by doing.
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
npm install -g node-gyp
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
If correctly compiles and runs the tests you are golden. We can now try to install the mongod driver by performing the following command.
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
cd yourproject
|
|
93
|
+
npm install mongodb --save
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
If it still fails the next step is to examine the npm log. Rerun the command but in this case in verbose mode.
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
npm --loglevel verbose install mongodb
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This will print out all the steps npm is performing while trying to install the module.
|
|
103
|
+
|
|
104
|
+
### Diagnosing on Windows
|
|
105
|
+
|
|
106
|
+
A known compiler tool chain known to work for compiling `kerberos` on windows is the following.
|
|
107
|
+
|
|
108
|
+
* Visual Studio c++ 2010 (do not use higher versions)
|
|
109
|
+
* Windows 7 64bit SDK
|
|
110
|
+
* Python 2.7 or higher
|
|
111
|
+
|
|
112
|
+
Open visual studio command prompt. Ensure node.exe is in your path and install node-gyp.
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
npm install -g node-gyp
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Next you will have to build the project manually to test it. Use any tool you use with git and grab the repo.
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
git clone https://github.com/christkv/kerberos.git
|
|
122
|
+
cd kerberos
|
|
123
|
+
npm install
|
|
124
|
+
node-gyp rebuild
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
This should rebuild the driver successfully if you have everything set up correctly.
|
|
128
|
+
|
|
129
|
+
### Other possible issues
|
|
130
|
+
|
|
131
|
+
Your python installation might be hosed making gyp break. I always recommend that you test your deployment environment first by trying to build node itself on the server in question as this should unearth any issues with broken packages (and there are a lot of broken packages out there).
|
|
132
|
+
|
|
133
|
+
Another thing is to ensure your user has write permission to wherever the node modules are being installed.
|
|
134
|
+
|
|
44
135
|
QuickStart
|
|
45
136
|
==========
|
|
46
|
-
The quick start guide will show you how to setup a simple application using node.js and MongoDB.
|
|
137
|
+
The quick start guide will show you how to setup a simple application using node.js and MongoDB. Its scope is only how to set up the driver and perform the simple crud operations. For more in depth coverage we encourage reading the tutorials.
|
|
47
138
|
|
|
48
139
|
Create the package.json file
|
|
49
140
|
----------------------------
|
|
@@ -136,7 +227,7 @@ var insertDocuments = function(db, callback) {
|
|
|
136
227
|
// Get the documents collection
|
|
137
228
|
var collection = db.collection('documents');
|
|
138
229
|
// Insert some documents
|
|
139
|
-
collection.
|
|
230
|
+
collection.insertMany([
|
|
140
231
|
{a : 1}, {a : 2}, {a : 3}
|
|
141
232
|
], function(err, result) {
|
|
142
233
|
assert.equal(err, null);
|
|
@@ -195,7 +286,7 @@ var updateDocument = function(db, callback) {
|
|
|
195
286
|
// Get the documents collection
|
|
196
287
|
var collection = db.collection('documents');
|
|
197
288
|
// Update document where a is 2, set b equal to 1
|
|
198
|
-
collection.
|
|
289
|
+
collection.updateOne({ a : 2 }
|
|
199
290
|
, { $set: { b : 1 } }, function(err, result) {
|
|
200
291
|
assert.equal(err, null);
|
|
201
292
|
assert.equal(1, result.result.n);
|
|
@@ -226,25 +317,26 @@ MongoClient.connect(url, function(err, db) {
|
|
|
226
317
|
});
|
|
227
318
|
```
|
|
228
319
|
|
|
229
|
-
|
|
320
|
+
Delete a document
|
|
230
321
|
-----------------
|
|
231
|
-
Next lets
|
|
322
|
+
Next lets delete the document where the field **a** equals to **3**.
|
|
232
323
|
|
|
233
324
|
```js
|
|
234
|
-
var
|
|
325
|
+
var deleteDocument = function(db, callback) {
|
|
235
326
|
// Get the documents collection
|
|
236
327
|
var collection = db.collection('documents');
|
|
237
328
|
// Insert some documents
|
|
238
|
-
collection.
|
|
329
|
+
collection.deleteOne({ a : 3 }, function(err, result) {
|
|
239
330
|
assert.equal(err, null);
|
|
240
331
|
assert.equal(1, result.result.n);
|
|
241
332
|
console.log("Removed the document with the field a equal to 3");
|
|
242
333
|
callback(result);
|
|
243
|
-
});
|
|
334
|
+
});
|
|
244
335
|
}
|
|
245
336
|
```
|
|
246
337
|
|
|
247
|
-
This will
|
|
338
|
+
This will delete the first document where the field **a** equals to **3**. Let's add the method to the **MongoClient
|
|
339
|
+
.connect** callback function.
|
|
248
340
|
|
|
249
341
|
```js
|
|
250
342
|
var MongoClient = require('mongodb').MongoClient
|
|
@@ -259,7 +351,7 @@ MongoClient.connect(url, function(err, db) {
|
|
|
259
351
|
|
|
260
352
|
insertDocuments(db, function() {
|
|
261
353
|
updateDocument(db, function() {
|
|
262
|
-
|
|
354
|
+
deleteDocument(db, function() {
|
|
263
355
|
db.close();
|
|
264
356
|
});
|
|
265
357
|
});
|
|
@@ -288,7 +380,8 @@ var findDocuments = function(db, callback) {
|
|
|
288
380
|
}
|
|
289
381
|
```
|
|
290
382
|
|
|
291
|
-
This query will return all the documents in the **documents** collection. Since we
|
|
383
|
+
This query will return all the documents in the **documents** collection. Since we deleted a document the total
|
|
384
|
+
documents returned is **2**. Finally let's add the findDocument method to the **MongoClient.connect** callback.
|
|
292
385
|
|
|
293
386
|
```js
|
|
294
387
|
var MongoClient = require('mongodb').MongoClient
|
|
@@ -303,7 +396,7 @@ MongoClient.connect(url, function(err, db) {
|
|
|
303
396
|
|
|
304
397
|
insertDocuments(db, function() {
|
|
305
398
|
updateDocument(db, function() {
|
|
306
|
-
|
|
399
|
+
deleteDocument(db, function() {
|
|
307
400
|
findDocuments(db, function() {
|
|
308
401
|
db.close();
|
|
309
402
|
});
|
package/conf.json
CHANGED
|
@@ -5,21 +5,25 @@
|
|
|
5
5
|
"test/functional/operation_example_tests.js",
|
|
6
6
|
"test/functional/operation_promises_example_tests.js",
|
|
7
7
|
"test/functional/operation_generators_example_tests.js",
|
|
8
|
-
"
|
|
8
|
+
"test/functional/authentication_tests.js",
|
|
9
|
+
"test/functional/gridfs_stream_tests.js",
|
|
10
|
+
"lib/admin.js",
|
|
9
11
|
"lib/collection.js",
|
|
10
12
|
"lib/cursor.js",
|
|
11
|
-
"lib/aggregation_cursor.js",
|
|
13
|
+
"lib/aggregation_cursor.js",
|
|
12
14
|
"lib/command_cursor.js",
|
|
13
15
|
"lib/db.js",
|
|
14
|
-
"lib/mongo_client.js",
|
|
15
|
-
"lib/mongos.js",
|
|
16
|
-
"lib/read_preference.js",
|
|
17
|
-
"lib/replset.js",
|
|
18
|
-
"lib/server.js",
|
|
19
|
-
"lib/bulk/common.js",
|
|
20
|
-
"lib/bulk/ordered.js",
|
|
21
|
-
"lib/bulk/unordered.js",
|
|
16
|
+
"lib/mongo_client.js",
|
|
17
|
+
"lib/mongos.js",
|
|
18
|
+
"lib/read_preference.js",
|
|
19
|
+
"lib/replset.js",
|
|
20
|
+
"lib/server.js",
|
|
21
|
+
"lib/bulk/common.js",
|
|
22
|
+
"lib/bulk/ordered.js",
|
|
23
|
+
"lib/bulk/unordered.js",
|
|
22
24
|
"lib/gridfs/grid_store.js",
|
|
25
|
+
"node_modules/mongodb-core/lib/error.js",
|
|
26
|
+
"lib/gridfs-stream/index.js",
|
|
23
27
|
"node_modules/mongodb-core/lib/connection/logger.js",
|
|
24
28
|
"node_modules/bson/lib/bson/binary.js",
|
|
25
29
|
"node_modules/bson/lib/bson/code.js",
|
|
@@ -31,7 +35,7 @@
|
|
|
31
35
|
"node_modules/bson/lib/bson/timestamp.js",
|
|
32
36
|
"node_modules/bson/lib/bson/max_key.js",
|
|
33
37
|
"node_modules/bson/lib/bson/min_key.js"
|
|
34
|
-
]
|
|
38
|
+
]
|
|
35
39
|
},
|
|
36
40
|
"templates": {
|
|
37
41
|
"cleverLinks": true,
|
|
@@ -55,7 +59,7 @@
|
|
|
55
59
|
"keyword": ""
|
|
56
60
|
},
|
|
57
61
|
"linenums": true
|
|
58
|
-
},
|
|
62
|
+
},
|
|
59
63
|
"markdown": {
|
|
60
64
|
"parser": "gfm",
|
|
61
65
|
"hardwrap": true,
|
|
@@ -64,4 +68,4 @@
|
|
|
64
68
|
"examples": {
|
|
65
69
|
"indent": 4
|
|
66
70
|
}
|
|
67
|
-
}
|
|
71
|
+
}
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Core module
|
|
2
|
-
var core = require('mongodb-core')
|
|
2
|
+
var core = require('mongodb-core'),
|
|
3
|
+
Instrumentation = require('./lib/apm');
|
|
3
4
|
|
|
4
5
|
// Set up the connect function
|
|
5
6
|
var connect = require('./lib/mongo_client').connect;
|
|
@@ -8,6 +9,7 @@ var connect = require('./lib/mongo_client').connect;
|
|
|
8
9
|
connect.MongoError = core.MongoError;
|
|
9
10
|
|
|
10
11
|
// Actual driver classes exported
|
|
12
|
+
connect.Admin = require('./lib/admin');
|
|
11
13
|
connect.MongoClient = require('./lib/mongo_client');
|
|
12
14
|
connect.Db = require('./lib/db');
|
|
13
15
|
connect.Collection = require('./lib/collection');
|
|
@@ -19,10 +21,12 @@ connect.GridStore = require('./lib/gridfs/grid_store');
|
|
|
19
21
|
connect.Chunk = require('./lib/gridfs/chunk');
|
|
20
22
|
connect.Logger = core.Logger;
|
|
21
23
|
connect.Cursor = require('./lib/cursor');
|
|
24
|
+
connect.GridFSBucket = require('./lib/gridfs-stream');
|
|
22
25
|
|
|
23
26
|
// BSON types exported
|
|
24
27
|
connect.Binary = core.BSON.Binary;
|
|
25
28
|
connect.Code = core.BSON.Code;
|
|
29
|
+
connect.Map = core.BSON.Map;
|
|
26
30
|
connect.DBRef = core.BSON.DBRef;
|
|
27
31
|
connect.Double = core.BSON.Double;
|
|
28
32
|
connect.Long = core.BSON.Long;
|
|
@@ -35,5 +39,12 @@ connect.Timestamp = core.BSON.Timestamp;
|
|
|
35
39
|
|
|
36
40
|
// Add connect method
|
|
37
41
|
connect.connect = connect;
|
|
42
|
+
|
|
43
|
+
// Set up the instrumentation method
|
|
44
|
+
connect.instrument = function(options, callback) {
|
|
45
|
+
if(typeof options == 'function') callback = options, options = {};
|
|
46
|
+
return new Instrumentation(core, options, callback);
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
// Set our exports to be the connect function
|
|
39
|
-
module.exports = connect;
|
|
50
|
+
module.exports = connect;
|