sqlite
This commit is contained in:
@@ -23,18 +23,26 @@
|
||||
|
||||
/**
|
||||
* Checks whether an error is a unique-constraint violation.
|
||||
* @param {unknown} err
|
||||
* @param {any} err
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isUniqueConstraintError(err) {
|
||||
throw new Error('Not implemented: isUniqueConstraintError');
|
||||
return (
|
||||
err?.number === 2627 ||
|
||||
err?.number === 2601 ||
|
||||
err?.code === 'SQLITE_CONSTRAINT_UNIQUE' ||
|
||||
err?.code === 'SQLITE_CONSTRAINT_PRIMARYKEY'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether an error is a foreign-key-constraint violation.
|
||||
* @param {unknown} err
|
||||
* @param {any} err
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isForeignKeyConstraintError(err) {
|
||||
throw new Error('Not implemented: isForeignKeyConstraintError');
|
||||
return (
|
||||
err?.number === 547 ||
|
||||
err?.code === 'SQLITE_CONSTRAINT_FOREIGNKEY'
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user