forked from mongodb/node-mongodb-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
76 lines (66 loc) · 2.36 KB
/
index.js
File metadata and controls
76 lines (66 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
'use strict';
const error = require('./lib/error');
const Instrumentation = require('./lib/apm');
const { BSON } = require('./lib/deps');
const { Cursor, AggregationCursor, CommandCursor } = require('./lib/cursor');
const PromiseProvider = require('./lib/promise_provider');
// Set up the connect function
const connect = require('./lib/mongo_client').connect;
Object.defineProperty(connect, 'Promise', {
get: function() {
return PromiseProvider.get();
},
set: function(lib) {
PromiseProvider.set(lib);
}
});
// Expose error class
connect.MongoError = error.MongoError;
connect.MongoNetworkError = error.MongoNetworkError;
connect.MongoTimeoutError = error.MongoTimeoutError;
connect.MongoServerSelectionError = error.MongoServerSelectionError;
connect.MongoParseError = error.MongoParseError;
connect.MongoWriteConcernError = error.MongoWriteConcernError;
connect.MongoBulkWriteError = require('./lib/bulk/common').BulkWriteError;
connect.BulkWriteError = connect.MongoBulkWriteError;
// Actual driver classes exported
connect.Admin = require('./lib/admin');
connect.MongoClient = require('./lib/mongo_client');
connect.Db = require('./lib/db');
connect.Collection = require('./lib/collection');
connect.ReadPreference = require('./lib/read_preference');
connect.Logger = require('./lib/logger');
connect.AggregationCursor = AggregationCursor;
connect.CommandCursor = CommandCursor;
connect.Cursor = Cursor;
connect.GridFSBucket = require('./lib/gridfs-stream');
// BSON types exported
connect.Binary = BSON.Binary;
connect.Code = BSON.Code;
connect.Map = BSON.Map;
connect.DBRef = BSON.DBRef;
connect.Double = BSON.Double;
connect.Int32 = BSON.Int32;
connect.Long = BSON.Long;
connect.MinKey = BSON.MinKey;
connect.MaxKey = BSON.MaxKey;
connect.ObjectID = BSON.ObjectID;
connect.ObjectId = BSON.ObjectID;
connect.BSONSymbol = BSON.BSONSymbol;
connect.Timestamp = BSON.Timestamp;
connect.BSONRegExp = BSON.BSONRegExp;
connect.Decimal128 = BSON.Decimal128;
// Add connect method
connect.connect = connect;
// Set up the instrumentation method
connect.instrument = function(options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
const instrumentation = new Instrumentation();
instrumentation.instrument(connect.MongoClient, callback);
return instrumentation;
};
// Set our exports to be the connect function
module.exports = connect;