You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This also works, and much simpler to read, however it's coupled to db.user (or some other table) for no reason at all. (Also, it needs at least one record in the respective table).
I was thinking, what if there was not only db.$query but also db.$get and possibly db.$take / db.$takeOptional? Or perhaps some common raw SQL wrapper with "usual" ORM methods like db.$raw.select/get/take/...(something else?)...?
The text was updated successfully, but these errors were encountered:
This needs some thinking about what to add, how to add, what to depreciate and remove, I'd like to postpone this for later, since it's already doable just somewhat messy.
Ideally:
get for a single value, throws when not found, and I'm still considering renaming it to getOrThrow for explicitness
pluck for a flat array of values
exec for no result
etc.
transform if you wish to transform the value in a callback. No problem to map the result, but the chained transform may be a bit more declarative.
type to use a column type for both typing and parsing, so decimal is parsed in a way how it's configured (Decimal lib in your case).
Uh oh!
There was an error while loading. Please reload this page.
As a developer, sometimes I need to fetch a single value with raw SQL, such as the next value in sequence. Currently, the proposed way is:
This works, but is somewhat ugly.
Another approach is abusing
db.table.get
:This also works, and much simpler to read, however it's coupled to
db.user
(or some other table) for no reason at all. (Also, it needs at least one record in the respective table).I was thinking, what if there was not only
db.$query
but alsodb.$get
and possiblydb.$take
/db.$takeOptional
? Or perhaps some common raw SQL wrapper with "usual" ORM methods likedb.$raw.select/get/take/...(something else?)...
?The text was updated successfully, but these errors were encountered: