Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

andonis many to many attach

const user = await User.find(1)
const project = await Project.find(1)

await user.related('projects').attach([project.id])
// or
await user.related('projects').attach({
  [project.id]: {
    role: 'admin'
  }
})
Source by docs.adonisjs.com #
 
PREVIOUS NEXT
Tagged: #andonis #attach
ADD COMMENT
Topic
Name
1+4 =