1.0.3 • Published 2 years ago

pg-constants v1.0.3

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

pg-constants

CI NPM Version Minimum Node.js Version

Library with mapping of codes and messages to identify PostgreSQL errors.

Example

Catch an error when trying to create a row in a database that conflicts with another.

import { PgErrors } from 'pg-constants';

try {
  await user.save();
} catch (e) {
  if (e.code === PgErrors.UNIQUE_VIOLATION) {
    throw new Error('User with such email already exists');
  }
  throw e;
}
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.1

2 years ago