1.0.2 • Published 1 year ago

@renda_ardy/pg-error-constants v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

PG Error Constants

PostgresQL error constants for use with Node.js. Use these to avoid code like if (err.code === '23505') and instead write if (err.code === UNIQUE_VIOLATION).

Installation

npm install --save @renda_ardy/pg-error-constants

Usage

const { UNIQUE_VIOLATION } = require('@renda_ardy/pg-error-constants')

// ...
  .catch((err) => {
    if (err.code === UNIQUE_VIOLATION && err.constraint === 'user_name_key') {
      throw new UserError('That name is already taken')
    }

    throw err
  })

Constants

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago