© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
2 replies
Kasper

How to insert many rows with one-to-many relationships

I have 100+ rows I want to insert into an
artists
artists
table, and at the same time insert each artist's songs into a
songs
songs
table. Each song would be linked to the artist ID, but the artist ID would be generated by the query itself. Any way to accomplish this with Drizzle?

Basically, I have data like this I want to insert:
[
  {
    artist: "example",
    songs: [
      { title: "A" },
      // ...
    ]
  },
  // ...
]
[
  {
    artist: "example",
    songs: [
      { title: "A" },
      // ...
    ]
  },
  // ...
]
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Insert One to Many
Drizzle TeamDTDrizzle Team / help
3y ago
Relationships: Self one-one & one-many
Drizzle TeamDTDrizzle Team / help
3y ago
Utilizing Many-to-Many relationships
Drizzle TeamDTDrizzle Team / help
3y ago
Cannot insert rows with drizzle
Drizzle TeamDTDrizzle Team / help
2y ago