Revert "Eliminate if-statement (#3556)"

This reverts commit fb8b0c291dff0bec2aca85fda34ebff9c8c49b91.
This commit is contained in:
syuilo 2018-12-09 13:21:42 +09:00
parent 7bd67daf07
commit 3fc3893abc

View File

@ -61,7 +61,11 @@ export default abstract class Chart<T> {
constructor(name: string, grouped = false) {
this.collection = db.get<Log<T>>(`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