Retrieve checked value in edit form #4267
Replies: 1 comment
-
First, the error is correct, AdonisJS 5 doesn't have a Second, if I'm understanding correctly, you're just trying to get If so, you have a couple of options. // loop over the returned items to grab just the selected column
const userPermissionIds = (await user.related('permissions').query().select('id')).map(user => user.id)
// query your pivot table directly
const userPermissionIds = await Database
.from('users_permissions')
.where('user_id', user.id)
.select('permission_id') Or, you could even add in your own macro to the query builder that would allow you to do something like: const userPermissionIds = await user.related('permissions').query().selectIds() You can find more info on that approach here if you'd like: https://adocasts.com/lessons/my-favorite-adonisjs-model-query-builder-macros |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to retrieve checked value in AdonisJS, but I don't know how to retrieve checked value when I click edit
My table
users
permissions
users_permissions
My
edit.edge
fileMy
UsersController.ts
fileI've trying to using pluck but it return an error
"Property 'pluck' does not exist on type 'DatabaseQueryBuilderContract<any>'.
In older version, it works. How to retrieve a checked value like this image everytime I click edit users? I try this code in top it won't work.Beta Was this translation helpful? Give feedback.
All reactions