All Projects → nihalgonsalves → pg-error-enum

nihalgonsalves / pg-error-enum

Licence: MIT license
TypeScript Enum for Postgres Errors with no runtime dependencies. Also compatible with plain JavaScript.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to pg-error-enum

node-backend-template
A template for NodeJS backend projects
Stars: ✭ 19 (+5.56%)
Mutual labels:  postgres, typeorm
teanjs
🔥 TypeORM - Express - Angular 8 - NestJS Server Side Rendering (SSR) 😺
Stars: ✭ 62 (+244.44%)
Mutual labels:  postgres, typeorm
gobarber-api-gostack11
API GoBarber / NodeJS / Express / Typescript / SOLID
Stars: ✭ 39 (+116.67%)
Mutual labels:  postgres, typeorm
Pgcli
Postgres CLI with autocompletion and syntax highlighting
Stars: ✭ 9,985 (+55372.22%)
Mutual labels:  postgres, psql
dlock
Interval Lock
Stars: ✭ 19 (+5.56%)
Mutual labels:  postgres
nestjs-rest-cqrs-example
Example for Nest.js, MySQL, Redis, REST api, CQRS, DDD
Stars: ✭ 263 (+1361.11%)
Mutual labels:  typeorm
postgresql-resilient
Automatic re-connection support for PostgreSQL.
Stars: ✭ 16 (-11.11%)
Mutual labels:  postgres
go-pg-crud
Simple Postgres CRUD written in Golang
Stars: ✭ 44 (+144.44%)
Mutual labels:  postgres
apollo-instagram-clone
Apollogram | A place where you could share photos, like media, and follow peoples.
Stars: ✭ 24 (+33.33%)
Mutual labels:  typeorm
ng-nest-cnode
Angular 10 Front-End and Nestjs 7 framework Back-End build Fullstack CNode
Stars: ✭ 17 (-5.56%)
Mutual labels:  typeorm
safe-typeorm
TypeORM helper library enhancing safety in the compilation level
Stars: ✭ 160 (+788.89%)
Mutual labels:  typeorm
create-fastify-app
An utility that help you to generate or add plugin to your Fastify project
Stars: ✭ 53 (+194.44%)
Mutual labels:  postgres
terraform-aws-druid
Terraform module to deploy Apache Druid in Kubernetes
Stars: ✭ 16 (-11.11%)
Mutual labels:  postgres
nim-gatabase
Connection-Pooling Compile-Time ORM for Nim
Stars: ✭ 103 (+472.22%)
Mutual labels:  postgres
wait-for-pg
Check if PostgreSQL database is ready
Stars: ✭ 22 (+22.22%)
Mutual labels:  postgres
nest-admin
采用nestjs typeorm vue开发的一套权限管理系统
Stars: ✭ 256 (+1322.22%)
Mutual labels:  typeorm
renestql
React, NestJS & GraphQL monorepo boilerplate managed with nx
Stars: ✭ 25 (+38.89%)
Mutual labels:  typeorm
pg migrate
Manage postgres schema, triggers, procedures, and views
Stars: ✭ 25 (+38.89%)
Mutual labels:  postgres
general-angular
Realtime Angular Admin/CRUD Front End App
Stars: ✭ 24 (+33.33%)
Mutual labels:  postgres
api.pokedextracker.com
API for pokedextracker.com
Stars: ✭ 38 (+111.11%)
Mutual labels:  postgres

pg-error-enum

npm version build status

TypeScript Enum for Postgres Errors with no runtime dependencies. Also compatible with plain JavaScript.

Quick Start

Installation

# Using npm
npm install --save pg-error-enum

# Using yarn
yarn add pg-error-enum

Usage

TypeScript or ES6 Modules

import { PostgresError } from 'pg-error-enum';

JavaScript

const PostgresError = require('pg-error-enum').PostgresError;

Usage

if (error.code === PostgresError.UNIQUE_VIOLATION) {
  throw new Error('That username is taken');
}

Generation

The Enum is generated directly from errcodes.txt in the Postgres repository.

It follows the syntax defined in the text file, i.e., in short:

  1. Lines beginning with # and empty lines are ignored.

  2. Sections are parsed using:

    const sectionRegex = /^Section:\s(?<description>.*)$/;
  3. Each error code is parsed using:

    const errorLineRegex =
      /^(?<sqlstate>[A-Z0-9]*)\s*(?<severity>[EWS])\s*ERRCODE_(?<constant>[A-Z_]*)\s*(?<code>[a-z_]*)$/;
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].