From b1b5a795c864fb421c7b3508e14fded569479042 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 9 Dec 2018 13:21:42 +0900 Subject: [PATCH] Revert "Eliminate if-statement (#3556)" This reverts commit fb8b0c291dff0bec2aca85fda34ebff9c8c49b91. --- src/chart/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/chart/index.ts b/src/chart/index.ts index aff30bf0f..b59ad7602 100644 --- a/src/chart/index.ts +++ b/src/chart/index.ts @@ -61,7 +61,11 @@ export default abstract class Chart { constructor(name: string, grouped = false) { this.collection = db.get>(`chart.${name}`); - this.collection.createIndex({ span: -1, date: -1, group: grouped ? -1 : undefined }, { unique: true }); + if (grouped) { + this.collection.createIndex({ span: -1, date: -1, group: -1 }, { unique: true }); + } else { + this.collection.createIndex({ span: -1, date: -1 }, { unique: true }); + } } @autobind