diff --git a/src/chart/index.ts b/src/chart/index.ts index b59ad7602..913d49bec 100644 --- a/src/chart/index.ts +++ b/src/chart/index.ts @@ -61,11 +61,13 @@ export default abstract class Chart { constructor(name: string, grouped = false) { this.collection = db.get>(`chart.${name}`); - if (grouped) { - this.collection.createIndex({ span: -1, date: -1, group: -1 }, { unique: true }); - } else { - this.collection.createIndex({ span: -1, date: -1 }, { unique: true }); - } + const keys = { + span: -1, + date: -1 + }; + if (grouped) + keys.group = -1; + this.collection.createIndex(keys, { unique: true }); } @autobind