minor mongoclient class fix + added tests

This commit is contained in:
basarat
2013-08-27 22:46:05 +10:00
parent 653614727f
commit 198283a74c
2 changed files with 36 additions and 3 deletions
+25
View File
@@ -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();
});
});
})
+11 -3
View File
@@ -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);