mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-11 11:50:54 +08:00
minor mongoclient class fix + added tests
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
///<reference path="mongodb.d.ts"/>
|
||||
|
||||
// Test source : https://github.com/mongodb/node-mongodb-native
|
||||
import mongodb = require('mongodb');
|
||||
var MongoClient = mongodb.MongoClient;
|
||||
|
||||
var format = require('util').format;
|
||||
MongoClient.connect('mongodb://127.0.0.1:27017/test', function (err, db) {
|
||||
if (err) throw err;
|
||||
|
||||
var collection = db.collection('test_insert');
|
||||
collection.insert({ a: 2 }, function (err, docs) {
|
||||
|
||||
collection.count(function (err, count) {
|
||||
console.log(format("count = %s", count));
|
||||
});
|
||||
|
||||
// Locate all the entries using find
|
||||
collection.find().toArray(function (err, results) {
|
||||
console.dir(results);
|
||||
// Let's close the db
|
||||
db.close();
|
||||
});
|
||||
});
|
||||
})
|
||||
Vendored
+11
-3
@@ -1,9 +1,17 @@
|
||||
// Project : https://github.com/mongodb/node-mongodb-native
|
||||
// Documentation : http://mongodb.github.io/node-mongodb-native/
|
||||
|
||||
|
||||
/// <reference path='../node/node.d.ts' />
|
||||
|
||||
declare module "mongodb" {
|
||||
|
||||
export function connect(uri: string, options: any, callback: (err: any, db: Db) => void);
|
||||
export function connect(uri: string, callback: (err: any, db: Db) => void);
|
||||
// Class documentation : http://mongodb.github.io/node-mongodb-native/api-generated/mongoclient.html
|
||||
export class MongoClient{
|
||||
constructor(serverConfig: any, options: any);
|
||||
|
||||
static connect(uri: string, options: any, callback: (err: any, db: Db) => void);
|
||||
static connect(uri: string, callback: (err: any, db: Db) => void);
|
||||
}
|
||||
|
||||
export class Server {
|
||||
constructor (host: string, port: number, opts?: ServerOptions);
|
||||
|
||||
Reference in New Issue
Block a user