From 18c1e2012af98ad8bba7448321ce7e9b98709044 Mon Sep 17 00:00:00 2001 From: Michele Date: Thu, 19 Jul 2018 11:50:18 +0200 Subject: [PATCH] added expire index --- day_init.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/day_init.js b/day_init.js index b48bf64..8bef682 100644 --- a/day_init.js +++ b/day_init.js @@ -1,13 +1,15 @@ -// v1.1 +// v1.2 var db = connect("192.168.0.1:27017/lastlogin"); var dd = function(x) { var s = x.toString(); if(s.length > 1){return s;} else { return "0"+s;}} var now = new Date(); var col = now.getFullYear() + dd(now.getMonth()+1) + dd(now.getDate()) print("creating index: ll_",col.slice(2)); db.getCollection("ll_"+col.slice(2)).createIndexes([{"date": 1},{"country": 1},{"user": 1,"date": -1}]) +db.getCollection("ll_"+col.slice(2)).createIndex({"date": -1},{expireAfterSeconds: 15552000, name: "expire"}) var db = connect("192.168.0.1:27017/katamail"); var dd = function(x) { var s = x.toString(); if(s.length > 1){return s;} else { return "0"+s;}} var now = new Date(); var col = now.getFullYear() + dd(now.getMonth()+1) + dd(now.getDate()) print("creating index: ll_",col.slice(2)); db.getCollection("ll_"+col.slice(2)).createIndexes([{"date": 1},{"country": 1},{"user": 1,"date": -1}]) +db.getCollection("ll_"+col.slice(2)).createIndex({"date": -1},{expireAfterSeconds: 15552000, name: "expire"}) \ No newline at end of file