mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-07-30 15:53:59 -05:00
25 lines
602 B
TypeScript
25 lines
602 B
TypeScript
import type { DBBoolean } from "~/db/tables";
|
|
|
|
/** Converts a JS boolean to the 0/1 representation SQLite stores booleans as. */
|
|
export function toDBBoolean(value: boolean): DBBoolean {
|
|
return value ? 1 : 0;
|
|
}
|
|
|
|
export function errorIsSqliteForeignKeyConstraintFailure(
|
|
error: unknown,
|
|
): error is Error {
|
|
return (
|
|
error instanceof Error &&
|
|
error?.message?.includes("FOREIGN KEY constraint failed")
|
|
);
|
|
}
|
|
|
|
export function errorIsSqliteUniqueConstraintFailure(
|
|
error: unknown,
|
|
): error is Error {
|
|
return (
|
|
error instanceof Error &&
|
|
error?.message?.includes("UNIQUE constraint failed")
|
|
);
|
|
}
|