"Redownloading" a full record

Hi everyone,
I have a publication for a pagination that returns a limited number of rows.

As we’ve discovered, rendering 3k records causes Meteor or the browser to simply hang, so limiting the fields returned has fixed this… however

We’ve now run into a situation where there is a need to download the complete record into the client. The problem is the record already exists locally due to the pagination with said limited fields.

I understand the whole pub/sub thing, but can’t find any good resources that explain how you can ask Meteor to resend a client data relating to a specific record (i.e. bypass the cache in minimongo).

I’ve tried creating a new subscription, along with the idea, when a specific view is loaded, but this has not worked.

Using React as the front-end.

Any help will be very much appreciated!

Cheers,
timeimp

You can on such demand invoke a Meteor method to fetch that specific document. That bypasses the entire pub/sub and minimongo.

2 Likes

Indeed, calling a meteor method is one option if you don’t need to observe changes of that document in real time. However I’m quite sure that if you subscribe to a separate publication which should fetch you a complete document, your minimongo should get updated. It’s a common use case.

There might be 2 problems

  • Check minimongo in meteor tools. If data is there, you should use tracker in your component.
  • Maybe your publication is incorrect. Even if you subscribe to a single document by id, you should return a cursor, meaning that you can’t use findOne.

Then maybe I didn’t/don’t understand what you’re asking. I tried to help solving the problem I believed you described here:

I was under the impression that you have a pubsub with limited fields and, in certain situations, you need instead a complete document. Had this been your problem, what I suggested would have solved it. Collection#findOne works perfectly fine in a method. But now it seems I don’t understand the problem.

Thanks everyone for your replies.

They are kind-of-helping me, but I am still a little stuck.

Essentially, I have 12k records that I need to paginate and/or search.

Would using Method.call be the best way to action these requests or is there some way I can load the paginated list, page-by-page and then load full details after opening a record?

Cheers,
timeimp

If I were you, I would create two methods; one for the paginated list of records and another one to load the document in full details.

Note that pagination can be a little tricky, especially if you have many entries to paginate (12k are relatively a lot). Recommend to read MongoDB Pagination, Fast & Consistent (medium)

Good idea. I will try to do that!

Just to clarify: when you subscribe to a collection, does that mean any calls to the server that use that collection will come from that 1 published source?

If I publish two endpoints with the same collection, how can I tell it MyCollection.find() to use which subscription?