Compare commits
2 Commits
fbd199c39a
...
6844b1fb24
Author | SHA1 | Date | |
---|---|---|---|
6844b1fb24 | |||
0d6b41abcf |
@ -28,6 +28,11 @@ export function handlePrismaError(errorObj: any, res: Response, source: string)
|
||||
res.status(404).json({ status: 'ERROR', errorcode: 'DB_ERROR', message: 'Relation object does not exist', meta: errorObj.meta });
|
||||
break;
|
||||
|
||||
// P2025 -> "An operation failed because it depends on one or more records that were required but not found. {cause}"
|
||||
case 'P2025':
|
||||
res.status(404).json({ status: 'ERROR', errorcode: 'DB_ERROR', message: 'Object does not exist', meta: errorObj.meta });
|
||||
break;
|
||||
|
||||
default:
|
||||
res.status(500).json({ status: 'ERROR', errorcode: 'DB_ERROR', message: 'An error occurred during the database operation' });
|
||||
break;
|
||||
|
@ -13,8 +13,8 @@ async function get(req: Request, res: Response) {
|
||||
} else {
|
||||
log.api?.debug('GET products Success:', req.query, value);
|
||||
|
||||
if (value.search !== undefined || value.id !== undefined) {
|
||||
// if search or get by id
|
||||
if (value.search !== undefined || value.id !== undefined || value.gtin !== undefined) {
|
||||
// if search or get by id/gtin
|
||||
await db
|
||||
.$transaction([
|
||||
// Same query for count and findMany
|
||||
|
Loading…
x
Reference in New Issue
Block a user