UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature toggles service. It provides different strategies for handling feature toggles.

45 lines 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const COLUMNS = ['id', 'name', 'description', 'lifetime_days']; const TABLE = 'feature_types'; class FeatureTypeStore { constructor(db, getLogger) { this.db = db; this.logger = getLogger('feature-type-store.ts'); } 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, }; } async get(id) { const row = await this.db(TABLE).where({ id }).first(); return this.rowToFeatureType(row); } async getByName(name) { const row = await this.db(TABLE).where({ name }).first(); return this.rowToFeatureType(row); } async delete(key) { await this.db(TABLE).where({ id: key }).del(); } async deleteAll() { await this.db(TABLE).del(); } destroy() { } async exists(key) { const result = await this.db.raw(`SELECT EXISTS (SELECT 1 FROM ${TABLE} WHERE id = ?) AS present`, [key]); const { present } = result.rows[0]; return present; } } exports.default = FeatureTypeStore; module.exports = FeatureTypeStore; //# sourceMappingURL=feature-type-store.js.map