-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
db.exists; and adding another wrapping object around a lateral join #126
Comments
I'm afraid I don't think either of these things is possible as it stands.
const songExists = await db.selectOne('songs', { title: "When I'm Sixty Four" }).run(pool) !== undefined; That doesn't seem terribly hacky to me ... ? Are you saying you'd prefer a |
All good! This also isn't really a request to add it, I just wanted to make sure there was nothing super simple that I was just missing! The reason it has that specific shape is because I have some static data that I'm then augmenting with user-specific data. To add some more context to my example above, I have some data for a It would be possible to splat those properties out up into the root of the object like this:
but that isn't really an accurate / semantically correct schema to describe what's happening, since this makes it seem possible for I wouldn't say that this is a common case either though, so if this seems like a really niche application to you and it would add a lot of complexity, then I wouldn't bother :) For the second query, yep that's basically what I am doing, but I'd like it to be done in the lateral join since my first query is returning multiple rows, so it would need to be a sql fragment rather than in JS land. So it would be nice for it to be joined via Something like this feels like it could be clean (and it's very satisfying to have everything come back in a single query :P)
I think it might be possible via manual sql but I'm not sure... maybe with a |
Yeah, OK. I think I'm going to leave the object wrapping as a bit niche. :) But I'll leave this open and have a bit more of a think about |
Hello! I'm not sure if I just missed it in the documentation, but is there any way to add an object wrapper around properties in a lateral join?
For example, if I have an entity
Song
that I want to augment with some user-specific properties, such that the final result looks like this:where the values of
isFavorited
andisSomething
come from other shortcut queries, how would I do this?userProjection
is a simple object wrapper and isn't its own query.I essentially want something like this and I'm not sure if it's possible right now and I'm just not doing it correctly:
Unrelated to this main issue, but also is there any shortcut method of doing something like
exists
to check if a row exists? Right now I'm kind of doing a hacky thing where I do aselectOne
and then (in regular TS) just rewrite it as!!property
to check its nullability, but it's not very nice...Thanks in advance!
The text was updated successfully, but these errors were encountered: