Skip to content

Commit a34512b

Browse files
krufabJessica Lord
authored and
Jessica Lord
committed
docs(mongo-client): the new method MongoClient().connect() was wrongly… (#1633)
* doc(mongo-client): the new method MongoClient().connect() was wrongly marked as deprecated instead of the old static MongoClient.connet()
1 parent b665a26 commit a34512b

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

lib/mongo_client.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ var parse = require('./url_parser'),
2222
* @fileOverview The **MongoClient** class is a class that allows for making Connections to MongoDB.
2323
*
2424
* @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
2541
* const MongoClient = require('mongodb').MongoClient;
2642
* const test = require('assert');
2743
* // Connection url
@@ -232,7 +248,6 @@ var define = (MongoClient.define = new Define('MongoClient', MongoClient, false)
232248
* @method
233249
* @param {MongoClient~connectCallback} [callback] The command result callback
234250
* @return {Promise<MongoClient>} returns Promise if no callback passed
235-
* @deprecated MongoClient.connect is deprecated, please use new MongoClient().connect() to connect.
236251
*/
237252
MongoClient.prototype.connect = function(callback) {
238253
// Validate options object
@@ -469,9 +484,9 @@ MongoClient.connect = function(url, options, callback) {
469484
options = options || {};
470485

471486
// Create client
472-
var mongoclient = new MongoClient(url, options);
487+
var mongoClient = new MongoClient(url, options);
473488
// Execute the connect method
474-
return mongoclient.connect(callback);
489+
return mongoClient.connect(callback);
475490
};
476491

477492
define.staticMethod('connect', { callback: true, promise: true });

0 commit comments

Comments
 (0)