when creating a record with prisma and attempting ...
# orm-help
t
when creating a record with prisma and attempting to also create some relations, what is the difference between using
createMany
and
create
with an array of objects?
r
I was not aware that you could pass an array to a nested
create
, I thought you had to use
createMany
. I have been trying to create deeply nested data and one thing that
createMany
will not let you do is pass more nested data to it. After a bit of testing I can do this:
Copy code
prisma.parent.create({
	data: {
		name: "parent",
		children: {
			create: [
				{
					name: "child 1",
					children: { create: [{ name: "grandchild 1" }] },
				},
				{ name: "child 2", },
			],
		},
	},
});
But that will not work with
createMany
t
my guess is that create many is a bulk operation where create[] is performing single inserts. but I am not sure