You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using `sequelize.validateIsUnique()` the first parameter must the the field to do the check on. Notice that`isUnique: sequelize.validateIsUnique('email')` is going to check for the `email` field on the table with the value of `User.email`. Based on the previous example, the query it performed was something like this ( depending on your database):
When using `sequelize.validateIsUnique()` the first parameter must the the field to do the check on. For example,`isUnique: sequelize.validateIsUnique('email')`. In order for the validation to pass for an existing instance, the primary keys for that instance will be used to exclude values for that instance. Based on the previous example, the query it performed was something like this ( depending on your database):
64
+
```
65
+
SELECT count(*) AS `count` FROM `users` AS `User` WHERE `User`.`email` = 'jdoe@example.com' AND `User `.`id` IS NOT NULL;
66
66
```
67
67
68
68
The second parameter allows you to define a custom error message. The default error message is: `'{{field}} must be unique'`. Using our previous example we could do something like this:
@@ -84,11 +84,14 @@ var User = sequelize.define('User', {
84
84
## Branch Strategy
85
85
The master branch will be the stable branch. Please submit your PRs against the development branch. Once tests are created for v1.0.0 I will be moving development to master.
86
86
87
-
## Issues
88
-
If you discover a bug, please create a ticket on Github. https://github.com/angelxmoreno/sequelize-isunique-validator/issues
87
+
## Testing
88
+
```
89
+
npm test
90
+
```
89
91
90
-
### Kown Issues
91
-
There aren't any tests! I will be writing tests after further testing, oh and after I finish learning how to test, obviously :stuck_out_tongue_winking_eye:
92
+
## Issues
93
+
If you discover a bug, please create a ticket on Github.
Pull requests are always welcomed. This is my first module contributed to the NodeJS ecosystem. I'm sure there are a few things that could be improved. Please point them out, provide feedback and suggestions. I am all ears!
0 commit comments