Hey, I'm trying to connect a n:m relation of Code ...
# orm-help
p
Hey, I'm trying to connect a n:m relation of Code and Tag like this:
Copy code
return context.prisma.createCode
    code: args.code,
    description: args.description,
    created_by: { connect: { id: args.id }},
	
    tags: { connect: { id: args.tags.id }},
});
The
created_by
field works, but the
tags
field doesn't, because
args.tags
is a list. But I don't know how to resolve this.
b
Copy code
tags: {
     connect: [args.tags.map(tag => return {id: tag.id})]
}
how about this?
💯 1
p
Thanks! I will give it a try
Thank you so much! It worked after a little tweaking:
Copy code
tags: {
    connect: args.tags.map(tag => { return {id: tag.id}}) 
},
👍 1