@stravigor/banner 0.4.6 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -65,7 +65,22 @@ export class DatabaseDriver implements FeatureStore {
|
|
|
65
65
|
entries: Array<{ feature: string; scope: ScopeKey; value: unknown }>
|
|
66
66
|
): Promise<void> {
|
|
67
67
|
if (entries.length === 0) return
|
|
68
|
-
|
|
68
|
+
if (entries.length === 1) {
|
|
69
|
+
await this.set(entries[0].feature, entries[0].scope, entries[0].value)
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
await this.sql.begin(async tx => {
|
|
74
|
+
for (const e of entries) {
|
|
75
|
+
const jsonValue = JSON.stringify(e.value)
|
|
76
|
+
await tx`
|
|
77
|
+
INSERT INTO "_strav_features" ("feature", "scope", "value", "created_at", "updated_at")
|
|
78
|
+
VALUES (${e.feature}, ${e.scope}, ${jsonValue}::jsonb, NOW(), NOW())
|
|
79
|
+
ON CONFLICT ("feature", "scope")
|
|
80
|
+
DO UPDATE SET "value" = ${jsonValue}::jsonb, "updated_at" = NOW()
|
|
81
|
+
`
|
|
82
|
+
}
|
|
83
|
+
})
|
|
69
84
|
}
|
|
70
85
|
|
|
71
86
|
async forget(feature: string, scope: ScopeKey): Promise<void> {
|