summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAya Morisawa <AyaMorisawa4869@gmail.com>2018-09-01 19:12:07 +0900
committerAya Morisawa <AyaMorisawa4869@gmail.com>2018-09-01 19:12:07 +0900
commit52aa64fcb6bef627da82c7d1515a5798a0d53684 (patch)
tree873829a970553d969a92894df589992e1311f19c /src
parentAdd type annotation (diff)
downloadsharkey-52aa64fcb6bef627da82c7d1515a5798a0d53684.tar.gz
sharkey-52aa64fcb6bef627da82c7d1515a5798a0d53684.tar.bz2
sharkey-52aa64fcb6bef627da82c7d1515a5798a0d53684.zip
Fix drop index
Diffstat (limited to 'src')
-rw-r--r--src/models/stats.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/models/stats.ts b/src/models/stats.ts
index 82c07aa678..d496f2c480 100644
--- a/src/models/stats.ts
+++ b/src/models/stats.ts
@@ -2,7 +2,12 @@ import * as mongo from 'mongodb';
import db from '../db/mongodb';
const Stats = db.get<IStats>('stats');
-Stats.dropIndex({ date: -1 } as any); // 後方互換性のため
+
+// 後方互換性のため
+Stats.dropIndex({ date: -1 } as any).catch((e: mongo.MongoError) => {
+ if (e.code !== 27) throw e;
+});
+
Stats.createIndex({ span: -1, date: -1 }, { unique: true });
export default Stats;