forked from RyanHirsch/irc-logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.js
35 lines (30 loc) · 709 Bytes
/
db.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var mongoose = require('mongoose'),
util = require('util'),
config = require('./config.json');
var connection_string = util.format(
'mongodb://%s:%s@%s:%d/%s',
config.mongo.user,
config.mongo.password,
config.mongo.hostname,
config.mongo.port,
config.mongo.database
);
mongoose.connect(connection_string);
var IRCLog = mongoose.model('IRCLog', {
ts: Date,
server: String,
channel: String,
message: String,
nick: String
});
var addLogItem = function(data) {
var item = new IRCLog(data);
item.save(function(err) {
if(err) {
console.log(err);
}
});
};
exports.log = {
add: addLogItem
};