Skip to content

Make EntityManager.executeQuery() signature return actual entity type #4

Description

@AbakumovAlexandr

When I'm trying a code like in the example from README.MD:

    getAllCustomers(): Promise<Customer[]> {
        let query = EntityQuery.from('Customers').orderBy('companyName');

        return this._em.executeQuery(query)
            .then(res => res.results)
            .catch((error) => {
                console.log(error);
                return Promise.reject(error);
            });
    }

It doesn't compile with an error:

Type 'Promise<Entity[]>' is not assignable to type 'Promise<Customer[]>'.

So I have to cast it to through any to the actual Entity type it supposed to return:

.then(res => res.results (res.results as any) as Customer[])

Can we change this method signature to return an actual entity type instead of Entity?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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