3 ms·
The SQL is preferable in this overly simple, cherry-picked case, but now do composition.
by randomdata 2y ago
The SQL is preferable in this overly simple, cherry-picked case, but now do composition.
- pavel_lishin 2y agoI've done composition in Objection ORM, and honestly, it's a fair amount of hassle. On our projects, which are moderately small, I genuinely don't know if it is/was worth the hassle of setting up, vs. writing some repeated code. (We also have a pretty decent testing culture in place, so I would be much more accepting of DRY-violations.)
- randomdata 2y agoI assume the above is based on said package? Wherein lies the hassle? bmws = Cars.query().where( { brand: "BMW" }).groupBy('year').orderBy('year') bmwAvg = bmws.select(avg('price')) bmwMin = bmws.select(min('price')) bmwMax = bmws.select(max('price'))