hi everyone, i’m new to prisma and trying to set up a many:many relationship. this involves having the concept of “users” and “workspaces” where a user can belong to many workspaces, and a workspace can have many users.
I am trying to set up a query where, when creating a user, I can also assign them to multiple workspaces at the same time. because of this I’m trying to use an updateMany method to find all of the applicable workspaces and add the newly created user to them. i’m sure it’s a matter of me not understanding the correct syntax, but this is what I have:
const createUser = async (parent, args, context, info) => {
const user = await context.prisma.createUser({
name: args.name
});
const workspaces = await context.prisma.updateManyWorkspaces({
where: {
id_in: args.workspaces
},
data: {
users: [{
connect: {
id: user.id
}
}]
}
});
return user;
}