I have a one to many relation between i.e. Product...
# orm-help
k
I have a one to many relation between i.e. Product and Store. I can already create new Products that refer to their one Store like this: `` return await ctx.prisma.product.create({ data: { ..._data, // establish connection with store store_productTostore: { connect: { store_id }, }, }, }); ``
data
contains the input for the new
product
I checked the table it indeed refers to the designated home. However, I can't get the
products
column in Home to refer to the set of keys it has
products
is an array of the same type of key.id. I tried changing the above to this but it doesn't work: `` return await ctx.prisma.store.update({ where: { store_id }, data: { products: { create: { ...data } } } }); ``
n
Hey @KJReactor 👋 did you get this resolved in the meantime? If no, could you please share the relevant parts of your data model? 🙂
also a quick tip: to render code blocks properly, you can use three backticks instead of two and it'll show up like this 🙂
Copy code
return await ctx.prisma.store.update({
    where: { store_id },
   data: {
     products: {
         create: { ...data }
     }
   }
});
k
Yes, I solved the issue. I don't recall how though. Thanks for asking. Thanks