-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathrouterLogger.js
57 lines (45 loc) · 1.31 KB
/
routerLogger.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var config = require('../config/database');
var winston = require('../config/winston');
var dbUrl = process.env.MONGODB_LOGS_URI || config.databaselogs || process.env.MONGODB_URI;
winston.info('VisitorCounterSchema dbUrl: '+dbUrl);
// mongoose.set('useFindAndModify', false); //??
// mongoose.set('useCreateIndex', true);
// mongoose.set('useUnifiedTopology', true);
var conn = mongoose.createConnection(dbUrl, { "autoIndex": true });
// var conn = mongoose.connect(dbUrl, { "useNewUrlParser": true, "autoIndex": true });
// db.getCollection('reqlogs').aggregate([ {$group:{_id:{id_project:"$id_project"}, "count":{$sum:1}}},{$sort:{"count":-1}}])
// db.getCollection('projects').find({"_id":ObjectId("5afeaf94404bff0014098f54")})
var RouterLoggerSchema = new Schema({
url: {
type: String,
index: true
},
fullurl: {
type: String,
index: true
},
// ip: {
// type: String,
// index: true
// },
// host: {
// type: String,
// index: true
// },
origin: {
type: String,
index: true
},
id_project: {
type: String,
index: true
//required: true
}
}, {
timestamps: true
}
);
var routerLogger = conn.model('router_logger', RouterLoggerSchema);
module.exports = routerLogger;