Open radiegtya opened 7 years ago
@radiegtya you can contoll it when publishing/subscribing to ProjectMembers (paged subscribing chunk by chunk)
then the one which is limiting is ProjectMembers it self. not the user inside it?? If you can limit the user inside it, please give example how to do it. Regards
both.js
ProjectMembers.join(Meteor.users, "userId", "user", ["username", "profile"]);
server.js
Meteor.publish('projectMembers', (selector = {}, options = {})=>{
const cursor = ProjectMembers.find(selector, options);
return ProjectMembers.publishJoinedCursors(cursor);
});
client.js
const limit = 5; //for example limiting 5
const myProjectId = "23456asdasda";
this.autorun(()=>{
this.subscribe('projectMembers',
{projectId: myProjectId, "user.username": {$regex: "", $options: 'i'}},
{limit: limit}
);
});
Yes, that will return 5 priject members only (with user data).
(tou can also combine with "skip" option (and youll need to pass skip and limit as arguments to publish, and sort in the same order both at client and at server).
The case is not that simple. How if i just want to fetch 3 users related to projectMembers, and sorted by username ascending. Because if you said that simply limit by projectMembers, the user will be randomly fetched by projectMembers._id asc
On Saturday, 3 December 2016, Petar Korponaić notifications@github.com wrote:
@radiegtya https://github.com/radiegtya you can contoll it when publishing/subscribing to ProjectMembers (paged subscribing chunk by chunk)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/perak/meteor-joins/issues/12#issuecomment-264647464, or mute the thread https://github.com/notifications/unsubscribe-auth/ACD71j18gkhd0V8gIvkbi1XyFSxnR1Gkks5rEZI-gaJpZM4LDVRe .
Just wanna ask how to limit fetched relations?
for example if the relational table has 1000+ rows.
for example:
Projects
Meteor.users
ProjectMembers
then ProjectMembers may have so many users inside