Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

Side-loading data into minimongo #423

Open
gunn opened this issue Feb 11, 2021 · 4 comments
Open

Side-loading data into minimongo #423

gunn opened this issue Feb 11, 2021 · 4 comments
Labels
in-discussion We are still discussing how to solve or implement it

Comments

@gunn
Copy link

gunn commented Feb 11, 2021

There should be a supported way to inject data directly into minimongo instead of by subscription and DDP, but still allow update by subscription later.

A common use case for this is to support SSR - the initial data to hydrate an app can be shipped as a JSON string with the html - library example.

In my app, eliminating the wait for the initial subscription would reduce page load time from ~4s to ~0.8s.

This code - https://github.com/kadirahq/fast-render/blob/master/lib/client/fast_render.js#L19-L90 might do the job, but it's 5 years old, and getting quite deep into meteor's internals.

@gunn
Copy link
Author

gunn commented Feb 11, 2021

It would be great if it was possible to inform the server that the documents were side-loaded so it didn't send the data again (although even if it does it's still a win).

The fast-render library has to monkey-patch some of Meteor's DDP methods to avoid errors when the same documents are loaded for a second time - https://github.com/kadirahq/fast-render/blob/master/lib/client/ddp_update.js

@filipenevola
Copy link
Collaborator

@filipenevola filipenevola added the in-discussion We are still discussing how to solve or implement it label Feb 11, 2021
@gunn
Copy link
Author

gunn commented Feb 11, 2021

Hi @filipenevola no I hadn't seen it, thank you.
Looking it over now, it's a very similar approach to fast-render, and has the same short-comings - If you subscribe to the data it still gets sent a second time, it does invasive (and here non-tested) patching of meteor's internals.

I also can't see that it would prevent the error: Expected not to find a document already present for an add

This is a fundamental bit of functionality, so I'd like to avoid extra dependencies like redis too.

@Saeeed-B
Copy link

Saeeed-B commented Feb 15, 2021

@gunn @filipenevola
Is it logical to check the server side of each route and return the appropriate data with it.
It costs a lot. And obviously not a good solution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in-discussion We are still discussing how to solve or implement it
Projects
None yet
Development

No branches or pull requests

3 participants