@@ -22,6 +22,22 @@ var parse = require('./url_parser'),
22
22
* @fileOverview The **MongoClient** class is a class that allows for making Connections to MongoDB.
23
23
*
24
24
* @example
25
+ * // Connect using a MongoClient instance
26
+ * const MongoClient = require('mongodb').MongoClient;
27
+ * const test = require('assert');
28
+ * // Connection url
29
+ * const url = 'mongodb://localhost:27017';
30
+ * // Database Name
31
+ * const dbName = 'test';
32
+ * // Connect using MongoClient
33
+ * const mongoClient = new MongoClient(url);
34
+ * mongoClient.connect(function(err, client) {
35
+ * const db = client.db(dbName);
36
+ * client.close();
37
+ * });
38
+ *
39
+ * @example
40
+ * // Connect using the MongoClient.connect static method
25
41
* const MongoClient = require('mongodb').MongoClient;
26
42
* const test = require('assert');
27
43
* // Connection url
@@ -232,7 +248,6 @@ var define = (MongoClient.define = new Define('MongoClient', MongoClient, false)
232
248
* @method
233
249
* @param {MongoClient~connectCallback } [callback] The command result callback
234
250
* @return {Promise<MongoClient> } returns Promise if no callback passed
235
- * @deprecated MongoClient.connect is deprecated, please use new MongoClient().connect() to connect.
236
251
*/
237
252
MongoClient . prototype . connect = function ( callback ) {
238
253
// Validate options object
@@ -469,9 +484,9 @@ MongoClient.connect = function(url, options, callback) {
469
484
options = options || { } ;
470
485
471
486
// Create client
472
- var mongoclient = new MongoClient ( url , options ) ;
487
+ var mongoClient = new MongoClient ( url , options ) ;
473
488
// Execute the connect method
474
- return mongoclient . connect ( callback ) ;
489
+ return mongoClient . connect ( callback ) ;
475
490
} ;
476
491
477
492
define . staticMethod ( 'connect' , { callback : true , promise : true } ) ;
0 commit comments