• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

u-wave / core / 19337281714

13 Nov 2025 03:48PM UTC coverage: 85.319% (+0.2%) from 85.077%
19337281714

push

github

web-flow
Store waitlist and booth state in SQLite instead of Redis (#657)

954 of 1135 branches covered (84.05%)

Branch coverage included in aggregate %.

194 of 230 new or added lines in 7 files covered. (84.35%)

3 existing lines in 2 files now uncovered.

10047 of 11759 relevant lines covered (85.44%)

96.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.31
/src/KeyValue.js
1
import { fromJson, json, jsonb } from './utils/sqlite.js';
1✔
2

1✔
3
export default class KeyValue {
1✔
4
  #db;
149✔
5

149✔
6
  /** @param {import('./schema.js').Kysely} db */
149✔
7
  constructor(db) {
149✔
8
    this.#db = db;
149✔
9
  }
149✔
10

149✔
11
  /** @param {string} key */
149✔
12
  async get(key, db = this.#db) {
149✔
13
    const row = await db.selectFrom('keyval')
204✔
14
      .select((eb) => json(eb.ref('value')).as('value'))
204✔
15
      .where('key', '=', key)
204✔
16
      .executeTakeFirst();
204✔
17
    if (row == null) {
204✔
18
      return undefined;
69✔
19
    }
69✔
20
    return fromJson(row.value);
135✔
21
  }
204✔
22

149✔
23
  /**
149✔
24
   * @param {string} key
149✔
25
   * @param {import('type-fest').JsonValue} value
149✔
26
   */
149✔
27
  async set(key, value, db = this.#db) {
149✔
28
    await db.insertInto('keyval')
90✔
29
      .values({ key, value: jsonb(value) })
90✔
30
      .onConflict((oc) => oc.column('key').doUpdateSet({ value: jsonb(value) }))
90✔
31
      .execute();
90✔
32
  }
90✔
33

149✔
34
  /**
149✔
35
   * Delete a key, returning its previous value if any.
149✔
36
   *
149✔
37
   * @param {string} key
149✔
38
   * @returns {Promise<import('type-fest').JsonValue | undefined>}
149✔
39
   */
149✔
40
  async delete(key, db = this.#db) {
149✔
41
    const existing = await db.deleteFrom('keyval')
36✔
42
      .where('key', '=', key)
36✔
43
      .returning((eb) => json(eb.ref('value')).as('value'))
36✔
44
      .executeTakeFirst();
36✔
45

36✔
46
    if (existing == null) {
36✔
47
      return undefined;
36✔
48
    }
36✔
NEW
49

×
NEW
50
    return fromJson(existing.value);
×
51
  }
36✔
52
}
149✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc