-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
I'm using bookshelf.js instead of knex and I want to check for unique using name and id attribute of the table.
How can I pass req.params in my custom function that checks for unique name in table?
Below is my code:
function assertEditRoleName(val, params, context) {
return Role
.forge()
.where('id', '<>', 2)
.where('name', '=', val)
.where('is_deleted', '=', 0)
.fetchAll()
.then(function (existing) {
if (existing.models.length > 0) {
throw new Error('Duplicated role name');
}
}).catch(function (err) {
console.log(err);
});
}
In above code, i'm getting only name in val and I want to pass id also from my request body.
I have checked #26
Thanks
Metadata
Metadata
Assignees
Labels
No labels