Thank you, guys. I just noticed Prisma has nice documentation explaining the differences, and I missed it before raising this discussion:
https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#create-a-single-record-and-multiple-related-records
Prisma
prisma.io › home › crud › crud › crud › crud
CRUD (Reference) | Prisma Documentation
Quickstart with Prisma Postgres if you want a managed database to try these examples against quickly · The id is auto-generated. Your schema determines which fields are mandatory. const createMany = await prisma.user.createMany({ data: [ { name: "Bob", email: "bob@prisma.io" }, { name: "Yewande", email: "yewande@prisma.io" }, ], skipDuplicates: true, // Skip records with duplicate unique fields }); // Returns: { count: 2 } skipDuplicates is not supported on MongoDB, SQLServer, or SQLite.
node.js - Prisma CreateMany Vs Transaction - Stack Overflow
To correct your last note re: performance - Prisma docs do state that: createMany uses a single INSERT INTO statement with multiple values rather than a single transaction. More on stackoverflow.com
How to createMany with a relation? Looping CREATE and getting "too many connections"?
hello! Let me see if i got this straight - I have what i believe to be a very simple issue: I create a batch of reports scores I create a bunch of scores in the batch Because you can't use crea... More on github.com
CreateMany while connecting to many
Prisma does not support the createMany operation with nested writes, which includes the connect operation for relations. The createMany operation is designed to create multiple records in a single model without handling relations. More on github.com
Prisma CreateMany with a relation (connect)
Hi everyone, in Prisma is there a way to createMany with relation - using connect i assume? Basically this a million times: I read the documentation and there doesn't seem to be "nested createMany" but i think that's not that im doing (or is it? More on answeroverflow.com
07:50
Prisma Tutorial for Beginners #3 - CRUD - Creating Records - YouTube
38:48
Prisma ORM Tutorial for Beginners | CRUD, CreateMany, Associations...
05:07
Prisma Tutorial for Beginners #4 - CRUD - Reading Records - YouTube
06:24
Implementing Bulk Inserts | Express API & Prisma ORM Query ...
Prisma
prisma.io › home › relation queries › relation queries › relation queries › relation queries
Relation queries (Concepts) | Prisma Documentation
Nested readsRelation load strategies (Preview)ExamplesWhen to use which load strategy?Include a relationInclude all fields for a specific relationInclude deeply nested relationsSelect specific fields of included relationsRelation countFilter a list of relationsNested writesCreate a related recordCreate a single record and multiple related recordsUsing nested createUsing nested createManyCreate multiple records and multiple related recordsConnect multiple recordsConnect a single recordConnect or create a recordDisconnect a related recordDisconnect all related recordsDelete all related recordsDe
Medium
medium.com › @enayetflweb › prisma-crud-operations-guide-211a15113e70
Prisma CRUD Operations Guide. This guide will walk you through using… | by Md Enayetur Rahman | Medium
October 26, 2024 - import { PrismaClient } from '@prisma/client'; // Initialize Prisma Client const prisma = new PrismaClient(); const main = async () => { const createMany = await prisma.post.createMany({ data: [ { title: 'title1', content: 'content1', authorName: 'authorName1', }, { title: 'title2', content: 'content2', authorName: 'authorName2', }, { title: 'title3', content: 'content3', authorName: 'authorName3', } ] }); console.log(createMany); // Outputs the count of records created }; main();
Prisma
prisma.io › home › prisma client api › prisma client api › prisma client api
Prisma Client API | Prisma Documentation
You cannot create or connect relations by using nested create, createMany, connect, connectOrCreate queries inside a top-level createManyAndReturn() query. See here for a workaround. When relations are included via include, a separate query is generated per relation. ... const users = await prisma.user.createManyAndReturn({ data: [ { name: "Sonali", email: "sonali@prisma.io" }, { name: "Alex", email: "alex@prisma.io" }, ], });
YouTube
youtube.com › prisma
Bulk Inserting Data with Prisma's createMany Method - YouTube
New at Prisma 2.16 is the createMany method. This method allows developers to bulk insert data instead of looping over a dataset and creating records one at ...
Published February 5, 2021 Views 28K
Answer Overflow
answeroverflow.com › m › 1066271029569278042
Prisma CreateMany with a relation (connect)
January 21, 2023 - const result = await prisma.posts.create({ data: { user: { connect: { id: user.id, }, }, ...postData, }, });
Top answer 1 of 2
4
Ok I found that this was actually quite simple... just do it as usual insert and include the forign key id.
const result = await prisma.posts.createMany([
{
...postData,
userId,
},
]);
2 of 2
0
This better works on my end. https://www.prisma.io/docs/orm/reference/prisma-client-reference#create
async function main() {
let users: Prisma.UserCreateInput[] = [
{
email: '[email protected]',
userId: { connect: { id }
},
{
email: '[email protected]',
userId: { connect: { id }
},
]
await Promise.all(
users.map(async (user) => {
await prisma.user.create({
data: user,
})
})
)
}
Reddit
reddit.com › r/node › help with prisma create many.
r/node on Reddit: Help with Prisma create many.
October 28, 2021 -
I want to be able to use prisma createMany in a nested object. Is this possible? Basically a deck has many sets and sets have many cards. I want to be able to create this all at once.
Like this:
const deck = await context.prisma.deck.create({
data: {
sets: { createMany: { data: [...newSets, cards: { createMany: {data: [...newCards]}}] } },
},
});GitHub
github.com › prisma › prisma › issues › 5455
Create nested relations using `createMany()` and `createMany` · Issue #5455 · prisma/prisma
February 3, 2021 - kind/featureA request for a new feature.A request for a new feature.topic: createManynested `createMany`nested `createMany`topic: createMany()topic: nested write (create/update/delete)https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#nested-writeshttps://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#nested-writestopic: relations
Author prisma
Medium
medium.com › @ivanspoljaric22 › mastering-bulk-inserts-in-prisma-best-practices-for-performance-integrity-2ba531f86f74
Mastering Bulk Inserts in Prisma: Best Practices for Performance & Integrity | by Ivan Spoljaric | Medium
February 14, 2025 - const data = [{ name: "A", ... }, { name: "B", ... }, ... ] const targetEntity = "..." // The name of a DB entity (table), defined in schema.prisma const records = await prisma.[targetEntity].createMany({ data }) const createdRecords = await prisma.[targetEntity].findMany({ where: { name: { in: data.map(item => item.name ) } } }); console.log(createdRecords) // [{ id: "1", ...
Medium
medium.com › @rsharma7_be22 › how-i-optimized-bulk-inserts-by-replacing-upsert-with-createmany-in-prisma-676fa74fb479
How I Optimized Bulk Inserts by Replacing .upsert with createMany in Prisma | by rohanS | Medium
July 30, 2025 - In a recent commit to my project getuplaced, I tackled a small but meaningful optimization: switching from repeatedly calling .upsert inside a Promise.all loop to a single createMany call. Let’s break down why this change makes sense and how it improved my code. Initially, I was iterating over an array of founders and running an upsert for each one: await Promise.all( founders.map((founder) => prisma.userFounderStatus.upsert({ where: { userId_founderId: { userId: user.id, founderId: founder.id, }, }, update: {}, create: { userId: user.id, founderId: founder.id, isSent: false, }, }) ) );
GitHub
github.com › prisma › prisma › issues › 8131
`createMany()` should return the created records · Issue #8131 · prisma/prisma
July 7, 2021 - The data to be created could be represented like so: Array<{post: PostData, comments: Array<CommentData>}>. If createMany returned the created data, I could do something like this: const inputs: Array<{post: PostData, comments: Array<CommentData>}> = [...]; const posts = prisma.post.createMany({data: [...]}); const commentCreateData = inputs.map((input, index) => input.comments.map((commentData) => ...))).flat(); prisma.comment.createMany({data: commentCreateData}); However, since createMany does not return the created data, it is difficult to create many posts and then create many comments linked to those posts in an efficient manner.
Author prisma