rom-sql icon indicating copy to clipboard operation
rom-sql copied to clipboard

Document relation#wrap

Open abrthel opened this issue 8 years ago • 0 comments

Docs need to further flesh out what Relation#wrap is used for and how it's used in comparison with Relation#combine

Notes

  • wrap should be used when you have an aggregate that always has associated data, in rom-sql it uses inner join to load it so basically you get all the data in one db query
  • compared to combine which queries each part individually; merging data happens in memory regardless
  • note that wrap uses inner joins, so users wrapping tanks would only return users that actually have tasks

Solnic mind dump

Wrap is a special type of a relation which returns data from multiple relations in a single "query", but that's just an implementation detail. What's important is that wraps represent a single "concept", even though the data comes from multiple sources. Basically when you use a wrap, it should mean that something always comes with additional data from other sources, ie a user with its address, a book with its pages etc.

when you use a combine, it means that ie you have a user, and some times you have a user with an address too one thing we will do in the near future, is that wrap will work with both embedded values based on prefixed attributes OR another table so you may have users.address_street users.address_city etc. and set it address as an embedded value for wrapping and maybe later on it will be moved to a separate table, and it'll continue work in the same way as before

abrthel avatar Jan 15 '18 17:01 abrthel