momentum-mod / website

Momentum Mod's main website.
https://momentum-mod.org
MIT License
58 stars 59 forks source link

Don't include `zones` field on maps on all MMap SELECTs #857

Closed tsa96 closed 2 weeks ago

tsa96 commented 11 months ago

The zones JSON field on the MMap table can be enormous, shouldn't be included in DB queries for/including MMap unless explicitly requested. This is quite annoying - we constantly do joins on other tables including MMap, plus Prisma's MMapSelect type of really ugly, needs booleans for every field you want to include.

Few methods I considered:

  1. Use an explicit Prisma.MMapSelect all over the place, probably include some kind of integration with the expandToIncludes function.
  2. Split out to a MapZones table, 1-1 w/ MMap, using mapID as primary key. Simplifies code quite a bit, but an extra DB table.
  3. Some Prisma Client Extension crap.

(2) is Prisma-agnostic but I'm not a fan of the extra table, so probably going with (1). Have a stash starting on this (started on this just now but realised isn't really necessary for ongoing PR) will pick it up in the future.