generated from AthennaIO/Template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from AthennaIO/develop
Give purpose to isUnique column option
- Loading branch information
Showing
10 changed files
with
186 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@athenna/database", | ||
"version": "4.10.0", | ||
"version": "4.11.0", | ||
"description": "The Athenna database handler for SQL/NoSQL.", | ||
"license": "MIT", | ||
"author": "João Lenon <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
Check failure on line 1 in src/exceptions/UniqueValueException.ts GitHub Actions / build
Check failure on line 1 in src/exceptions/UniqueValueException.ts GitHub Actions / build
|
||
* @athenna/database | ||
* | ||
* (c) João Lenon <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import { Exception } from '@athenna/common' | ||
|
||
export class UniqueValueException extends Exception { | ||
public constructor(records: Record<string, any>) { | ||
let values = Object.values(records) | ||
let properties = Object.keys(records) | ||
|
||
if (properties.length > 1) { | ||
values = values.join(', ') | ||
properties = properties.join(', ') | ||
} else { | ||
values = values[0] | ||
properties = properties[0] | ||
} | ||
|
||
super({ | ||
status: 500, | ||
code: 'E_UNIQUE_VALUE_ERROR', | ||
message: `The properties [${properties}] is unique in database and cannot be replicated.`, | ||
help: `Your properties [${properties}] has the option isUnique set to true in it's model, meaning that the values [${values}] could not be used because there is another record with it in your database. Try creating your record with a different value, or set the isUnique property to false.` | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters