【文件属性】:
文件名称:pg-error-constants:与Node.js一起使用的PostgresQL错误常量
文件大小:8KB
文件格式:ZIP
更新时间:2021-04-30 16:07:51
JavaScript
PG错误常数
与Node.js一起使用的PostgresQL错误常量。 使用这些可避免类似if (err.code === '23505') ,而应编写if (err.code === UNIQUE_VIOLATION) 。
安装
npm install --save pg-error-constants
用法
const { UNIQUE_VIOLATION } = require ( 'pg-error-constants' )
// ...
. catch ( ( err ) => {
if ( err . code === UNIQUE_VIOLATION && err . constraint === 'user_name_key' ) {
throw new UserError ( 'That name is already taken' )
}
【文件预览】:
pg-error-constants-master
----index.js(11KB)
----package.json(122B)
----readme.md(17KB)
----.gitignore(30B)