uneeb meer
uneeb meer

Reputation: 973

typeorm return limited rows with relations

I need to return relational data with limited rows, I have seen solutions using query builder how can we achieve the same thing using standard typeorm events?

return await Product.find({ relations: ['productSizes', 'productColors'] }); 

Upvotes: 2

Views: 1455

Answers (1)

Ayoub Touba
Ayoub Touba

Reputation: 2997

to make the limit for your product entity, you only need to add take:numberTolimit

return await Product.find({ relations: ['productSizes', 'productColors'],take:10 });

Ps : you can use skip - offset from where entities should be taken.

Upvotes: 2

Related Questions