Skip to content

feat: toArray() equivalent for findOne subqueries #1481

@kevin-dp

Description

@kevin-dp

When using includes (nested queries) we can use toArray to materialize the results of the nested query into an array instead of a collection. However, when the nested query uses findOne to return a single element it is annoying to have to deal with a singleton array. We want a toArray equivalent for this use case that simply returns that one element.

I'm questioning if "toArray" is a good name because it means we now have to introduce another function for subqueries that return a single element. But conceptually both are doing the same: materializing the underlying collection. So perhaps materialize(subquery) would be a better name and it will return an array if the underlying query returns multiple results and a single element if it's a singular query.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions