feat(db): Bun.SQL Kysely dialect for sqlite and postgres
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6c5a9fbad9
commit
8248a2ac27
11 files changed
+403
-1
No files matched your search
@@ -0,0 +1,14 @@
|
||||
/** Serialise a value for a JSON column (stored as text on both dialects). */
|
||||
export function toJson(v: unknown): string {
|
||||
return JSON.stringify(v);
|
||||
}
|
||||
|
||||
/** Parse a JSON column, returning `fallback` for null, undefined or invalid text. */
|
||||
export function fromJson<T>(s: string | null | undefined, fallback: T): T {
|
||||
if (s == null) return fallback;
|
||||
try {
|
||||
return JSON.parse(s) as T;
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user