Kurounin / Pagination

This package allows you to paginate the subscriptions over meteor's collections. It can be used in a Blaze template or in ReactJS.
MIT License
56 stars 22 forks source link

How to apply filters on joined collection data? #73

Closed rameshchinni525 closed 6 years ago

rameshchinni525 commented 6 years ago

I want to apply filters on joined collection with foreign key. I have two collections (Accounts and Users), Now I'm doing pagination for list of users. I want to filter and display only users who have trial account. Accounts collection is joined via foreign key to the users collections. Given sample data below.

Accounts:{ "_id":"fsdfjhsdjkfjk345j", "trialAccount":true } // After joined with Account collection Users: { " _id": "fhsdf789sdfysdhf", "name": "John", "accountId":"fsdfjhsdjkfjk345j", "account": { // joined collection "trialAccount": true } }

publishPagination(Users,{
name:"usersData" });

I'm able to display account.trialAccount value in the grid page, but not able to do filters on it. Giving empty records when i do this.

filters: { "account.trialAccount":true }

Can you explain how we can use your package to apply filters on joined content?

Kurounin commented 6 years ago

Hi,

Since mongo does not allow searching in a joined collection, there is no way to do a subscription to Users collection and filter by a column in Accounts collection. There are 2 workarounds: