Skip to content
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

Query doesn't return the right object type #220

Closed
mattia85 opened this issue May 17, 2019 · 2 comments
Closed

Query doesn't return the right object type #220

mattia85 opened this issue May 17, 2019 · 2 comments

Comments

@mattia85
Copy link

Hello,
i have a problem with the instance returned by the query operation (also with get op):

const store: DynamoStore<OrderModel> = new DynamoStore<OrderModel>(OrderModel);
const getOrder = await store
   .query()
   .index(indexName)
   .wherePartitionKey(order.storeOrderId)
   .whereSortKey().eq(order.selectedStoreId)
   .execSingle();

my expectation was that the type of the object returned from the above query should be the one declared during the store definition, but i'm getting a simply js Object instead of an OrderModel, any idea?

Thank you.

@michaelwittwer
Copy link
Member

Hi @mattia85
This is how the library is supposed to work, we don't create instances of the provided model class. So an instanceof check will always return false. The model class is only defined for metadata purposes, any business logic should be provided in pure helper methods.

@mattia85
Copy link
Author

ok @michaellieberherr, thanks for clarifying that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants