Users subscription acting differently from a normal collection


#1

I have two paginating subscriptions, one to DB.users and one to DB.others. DB.others is adding to the local database, as expected. I.e., on page 1 we have 50 others in minimongo, on page 2 we have 100 others in minimongo, on page 3 we have 150 others in minimongo, etc. DB.users does not, and instead minimongo seems to replace the users subscription data in minimongo each time it is paginated. Is this something baked into the users collection?
(The issue is not with how things are being displayed, but with how we expect them to be stored in minimongo. Trying to figure out why/how it works differently for users.)
Here are examples of the code (skip and limit are reactive):

Tracker.autorun(() => {
		Meteor.subscribe('others', {
			skip: pageNumber * resultsPerPage,
			limit: resultsPerPage,
		});
	});

others() {
		const skip = pageNumber * resultsPerPage;

		return DB.others.find({{skip: skip, limit: pagination.resultsPerPage}).map((doc) => {
			doc.otherId = doc._id;

			return doc;
		});
	},
Tracker.autorun( () => {
		Meteor.subscribe('allUserData', {
			skip: pageNumber * resultsPerPage,
			limit: resultsPerPage
		});
	});

users() {
		const skip = pageNumber * resultsPerPage;
		return DB.users.find().fetch();
	},

#2

In your example code the variables aren’t reactive?
Did you deliberately skip adding the reactive part in the example?


#3

Yeah, didn’t want to clutter up the post. That’s why I made a note that they are reactive.


#4

hmmm, I’m unsure why then

I suspect it’s because you’re doing the skip and limit in both the subscription and the query params?
If you are only loading the data for each page from the server, then there’s only one page at a time on the client. But by asking the client to skip a page worth of results, it ends up skipping the one page that is on the client, displaying either nothing or the wrong thing?


#5

I’ll edit the original post to be more clear, but the issue is with the data in minimongo. The users collection, minimongo only ever has the 50 user objects requested. With the others collection, it adds 50 objects to the minimongo each time. So on the first page, we have 50 in minimongo; on the second page, we have 100 in minimongo; etc. The skip and limit in the query params allows exercises (and strangely, users as well) to display the correct exercises instead of just adding to the visible list.