Skip to content

Commit

Permalink
Version 1.2.0
Browse files Browse the repository at this point in the history
* added index creation;
* added simple initialization errors longing;
* dependecies were updated.
  • Loading branch information
yurijmikhalevich committed Oct 19, 2015
1 parent d6ba0f9 commit 1552778
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions lib/winston-mongodb.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @module winston-mongodb
* @fileoverview Transport for outputting to a MongoDB database
* @fileoverview Winston transport for logging into MongoDB
* @license MIT
* @author charlie@nodejitsu.com (Charlie Robbins)
* @author 0@39.yt (Yurij Mikhalevich)
Expand Down Expand Up @@ -83,7 +83,15 @@ var MongoDB = exports.MongoDB = function(options) {

function setupDatabaseAndEmptyQueue(db) {
authorizeDb(db, function(err, db) {
if (err) {
console.error('winston-mongodb, initialization error: ', err);
return;
}
createCollection(db, function(err, db) {
if (err) {
console.error('winston-mongodb, initialization error: ', err);
return;
}
self.logDb = db;
processOpQueue();
});
Expand All @@ -102,8 +110,14 @@ var MongoDB = exports.MongoDB = function(options) {
if (self.capped) {
opts = {capped: true, size: self.cappedSize};
}
db.createCollection(self.collection, opts, function() {
cb(null, db);
db.createCollection(self.collection, opts, function(err, col) {
if (err) {
cb(err);
return;
}
col.createIndex({timestamp: -1}, function(err) {
cb(err, db);
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "winston-mongodb",
"license": "MIT",
"version": "1.1.2",
"version": "1.2.0",
"description": "A MongoDB transport for winston",
"author": "Charlie Robbins <charlie.robbins@gmail.com>",
"contributors": [
Expand Down

0 comments on commit 1552778

Please sign in to comment.