1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/lib/db/feature-type-store.js
Ivar Conradi Østhus cdfba8f7b1 feat: Adds last-seen dat on toggles
When an application updates metrics for a toggle we now
stores the timestamp on the toggle when it was last seen
used by an application. This will make it much easier to
detect toggles not in use anymore.

closes #642
2020-12-22 11:05:00 +01:00

28 lines
639 B
JavaScript

'use strict';
const COLUMNS = ['id', 'name', 'description', 'lifetime_days'];
const TABLE = 'feature_types';
class FeatureToggleStore {
constructor(db, getLogger) {
this.db = db;
this.logger = getLogger('feature-type-store.js');
}
async getAll() {
const rows = await this.db.select(COLUMNS).from(TABLE);
return rows.map(this.rowToFeatureType);
}
rowToFeatureType(row) {
return {
id: row.id,
name: row.name,
description: row.description,
lifetimeDays: row.lifetime_days,
};
}
}
module.exports = FeatureToggleStore;