Function: isDuplicateKeyError()
isDuplicateKeyError(
err):boolean
Defined in: service-core/src/database/DatabaseErrors.ts:24
Determines whether err is a unique/primary key violation reported by any of the supported database drivers:
- MongoDB: code
11000(or11001); - PostgreSQL: SQLSTATE
23505; - MySQL/MariaDB:
ER_DUP_ENTRY(errno1062); - SQLite (
better-sqlite3/sqlite3):SQLITE_CONSTRAINT_UNIQUE/SQLITE_CONSTRAINT_PRIMARYKEY, or a genericSQLITE_CONSTRAINTwhose message is aUNIQUE constraint failederror.
Parameters
err
any
The error to inspect.
Returns
boolean