mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Fix type of mongodb.connect (#27398)
It had never been updated from 2.x. Fixes #23548.
This commit is contained in:
committed by
Wesley Wigham
parent
f805351bd7
commit
5d63e04d34
Vendored
+3
-3
@@ -24,9 +24,9 @@ import { ObjectID } from 'bson';
|
||||
import { EventEmitter } from 'events';
|
||||
import { Readable, Writable } from "stream";
|
||||
|
||||
export function connect(uri: string, options?: MongoClientOptions): Promise<Db>;
|
||||
export function connect(uri: string, callback: MongoCallback<Db>): void;
|
||||
export function connect(uri: string, options: MongoClientOptions, callback: MongoCallback<Db>): void;
|
||||
export function connect(uri: string, options?: MongoClientOptions): Promise<MongoClient>;
|
||||
export function connect(uri: string, callback: MongoCallback<MongoClient>): void;
|
||||
export function connect(uri: string, options: MongoClientOptions, callback: MongoCallback<MongoClient>): void;
|
||||
|
||||
export { Binary, DBRef, Decimal128, Double, Long, MaxKey, MinKey, ObjectID, ObjectId, Timestamp } from 'bson';
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
import mongodb = require('mongodb');
|
||||
var MongoClient = mongodb.MongoClient;
|
||||
|
||||
const connectionString = 'mongodb://127.0.0.1:27017/test';
|
||||
|
||||
var format = require('util').format;
|
||||
let options: mongodb.MongoClientOptions = {
|
||||
authSource: ' ',
|
||||
@@ -30,7 +32,7 @@ let options: mongodb.MongoClientOptions = {
|
||||
promoteBuffers: false,
|
||||
useNewUrlParser: false
|
||||
}
|
||||
MongoClient.connect('mongodb://127.0.0.1:27017/test', options, function (err: mongodb.MongoError, client: mongodb.MongoClient) {
|
||||
MongoClient.connect(connectionString, options, function (err: mongodb.MongoError, client: mongodb.MongoClient) {
|
||||
if (err) throw err;
|
||||
const db = client.db('test');
|
||||
var collection = db.collection('test_insert');
|
||||
@@ -166,3 +168,11 @@ MongoClient.connect('mongodb://127.0.0.1:27017/test', options, function (err: mo
|
||||
const res: mongodb.Cursor<TestCollection> = testCollection.find({ _id: 123 });
|
||||
}
|
||||
})
|
||||
|
||||
let testFunc = async () => {
|
||||
let testClient: mongodb.MongoClient;
|
||||
testClient = await mongodb.connect(connectionString);
|
||||
};
|
||||
|
||||
mongodb.connect(connectionString, (err: mongodb.MongoError, client: mongodb.MongoClient) => {});
|
||||
mongodb.connect(connectionString, options, (err: mongodb.MongoError, client: mongodb.MongoClient) => {});
|
||||
|
||||
Reference in New Issue
Block a user