unleash-server
Version:
Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.
40 lines • 1.34 kB
JavaScript
export class DependentFeaturesStore {
constructor(db) {
this.db = db;
}
async upsert(featureDependency) {
const serializableFeatureDependency = {
parent: featureDependency.parent,
child: featureDependency.child,
enabled: featureDependency.enabled,
};
if ('variants' in featureDependency) {
serializableFeatureDependency.variants = JSON.stringify(featureDependency.variants);
}
// TODO: remove when we support multiple parents
await this.db('dependent_features')
.where('child', featureDependency.child)
.del();
await this.db('dependent_features')
.insert(serializableFeatureDependency)
.onConflict(['parent', 'child'])
.merge();
}
async delete(dependency) {
await this.db('dependent_features')
.where('parent', dependency.parent)
.andWhere('child', dependency.child)
.del();
}
async deleteAll(features) {
if (features) {
await this.db('dependent_features')
.whereIn('child', features)
.del();
}
else {
await this.db('dependent_features').del();
}
}
}
//# sourceMappingURL=dependent-features-store.js.map