Can someone please help me understand how to add o...
# orm-help
m
Can someone please help me understand how to add or remove records on a join table that is implicitly defined? Consider two models, Roles and Permissions, which are M:N I thought it would be like this:
Copy code
this.prisma.role.update({
                        where: { id: incomingRole.id },
                        data: {
                            name: incomingRole.name,
                            permissions: {
                                deleteMany: {
                                    id: { in: permissionsToDelete.map(permission => permission.id) }
                                },
                                create: permissionsToCreate.map(permissionName => {
                                    return {
                                        name: permissionName
                                    }
                                })
                            }
                        }
                    })
But now I'm thinking that would instead delete and create actually Permission records, instead of deleting rolePermission records. Update: I decided to just explicitly define the join. I really love the implicit join syntax, but reading through the Prisma docs, it seems like to use them in queries, I have to explicitly define them.
1