mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-10-01 23:58:36 -05:00
Move app to apps/web-react in pnpm workspace layout
This commit is contained in:
24
apps/web-react/app/utils/sql.ts
Normal file
24
apps/web-react/app/utils/sql.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
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")
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user