drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[FEATURE]: Many-to-many builder helper

Open anthonyshew opened this issue 2 years ago • 0 comments

Describe want to want

Piggybacking off of #703, it would be great if I there were a way to have a "many-to-many" builder so I don't have to write out as much code. Thinking of something like (pseudocode incoming):

// Using names from the Stackblitz in the linked issue...
const {   
  gamesToGenres,
  gameGenresRelation,
  genreGamesRelation,
  gamesToGenresRelations 
  } = manyToManyBuilder(games, gamesIdToLink, genres, genresIdToLink)

My motivation is to have a paved path instead of recreating the logic every time. It's enough code that it's easy to use the wrong id somewhere and create a problem for yourself. While I was trying to sort out of #703 was happening in my code or in Drizzle, I spent a pretty fair amount of time trying to make sure my tables were right.

I'd rather fall into the pit of success with a builder! 😄 The goal for the design of this feature is DX through simplicity. If someone wants to customize the relation variable names, junction table name, etc., they can write it them themselves.

anthonyshew avatar Jun 03 '23 21:06 anthonyshew