Updated mongodb to version 2.1

This commit is contained in:
CaselIT
2016-01-11 15:07:25 +01:00
parent 2ad4d4208b
commit 307572b0ba
2 changed files with 1299 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
///<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: mongodb.MongoError, db: mongodb.Db) {
if (err) throw err;
var collection = db.collection('test_insert');
collection.insertOne({ a: 2 }, function(err: mongodb.MongoError, docs: any) {
collection.count(function(err: mongodb.MongoError, count: any) {
console.log(format("count = %s", count));
});
// Locate all the entries using find
collection.find({}).toArray(function(err: mongodb.MongoError, results: any) {
console.dir(results);
// Let's close the db
db.close();
});
// Get some statistics
collection.stats(function(err: mongodb.MongoError, stats: any) {
console.log(stats.count + " documents");
});
});
})
+1269
View File
File diff suppressed because it is too large Load Diff