Are nested selects supported/planned? I can includ...
# orm-help
r
Are nested selects supported/planned? I can include the relation and filter it on the client, but a 'select as' would be nicer.
r
@Ralf Vogler 👋 Do you want to filter on the relations while fetching the parent’s data?
r
yes, but have the result as a separate field.
r
I would suggest creating a feature request here then for the above.
@Ralf Vogler I checked out the request you created, and a workaround could be something like this:
Copy code
await prisma.todo.findMany({
    include: {
      times: {
        where: { end: null },
        select: { start: true },
        orderBy: { start: 'desc' },
        take: 1,
      },
    },
  })
r
I read the docs on pagination but was confused about the difference of this
offset
to
limit
. Does it need to go through all the results or is it O(1)?
r
You can use both with Prisma, the cursor based pagination is more performant that offset based.
r
There's no cursor since it's not about pagination but just limiting the result to one row. But I guess the docs just mean that
skip
does not scale, not
take
.
r
Yeah.
take: 1
is just
limit 1
under the hood. So the above query should be fine for your use case.
r
ok, thanks. I'll leave the feature request open since there's no issue about subqueries. The above is fine if I just want that field, but it does not allow include all
times
as well.
r
but it does not allow include all 
times
 as well.
I didn’t get this point.
r
It does not allow to get all rows and get the result of this query, whereas with a subquery you'd get the result as an extra field.
👍 1