📅  最后修改于: 2022-03-11 14:48:20.238000             🧑  作者: Mango
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'
}
})