* Get a setting value by key, automatically deserializing to the correct type.
(key: K)
| 30 | * Get a setting value by key, automatically deserializing to the correct type. |
| 31 | */ |
| 32 | static async getValue<K extends KVStoreKey>(key: K): Promise<KVStoreValue<K> | null> { |
| 33 | const setting = await this.findBy('key', key) |
| 34 | if (!setting || setting.value === undefined || setting.value === null) { |
| 35 | return null |
| 36 | } |
| 37 | const raw = String(setting.value) |
| 38 | return (KV_STORE_SCHEMA[key] === 'boolean' ? parseBoolean(raw) : raw) as KVStoreValue<K> |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Set a setting value by key (creates if not exists), automatically serializing to string. |
no test coverage detected