Prioritize the push of certain documents

Hello :wave:

Is there a way to prioritize the push of a type of document ?

For example, in our application, we push two documents : a document A and a document B. They have a strong business link. When there is a push synchronization, the document A can be send first. But we need the document B first on the server side.

The merge of both documents into one new document is not a valid solution.

I read on this blog post that we can prioritize push/pull documents with channels. But I don’t really want to rely on this, because we already have some problems with channels.

Also, on this blog post, it said :

On the client-side, on initial launch, do a one-shot pull replication of the highest priority channel by specifying the channels filter. Once the sync of the documents in channel completes, the app can kick off another replication for the remaining channels.

But the status completed should not be used in this case or I don’t understand this part of the document :

The replication change object also has properties to track the progress ( change.status.completed and change.status.total ). But since the replication occurs in batches and the total count can vary through the course of a replication, those progress indicators are not very useful from the standpoint of an app user. Hence, these should not be used for tracking the actual progress of the replication.

In the push filter documentation, I find this interesting part :

A push filter allows an app to push a subset of a database to the server, which can be very useful in some circumstances. For instance, high-priority documents could be pushed first, or documents in a “draft” state could be skipped.

But there is no example, so this is hard to understand how we can achieve this, with only the Push Filter feature.

Thanks

1 Like

Note that channels are used in pull replication. So that has no bearing on push replication “prioritization”/

You can simulate prioritization by starting a one-shot replication of the high priority documents. Setup push filter to reject the lower priority documents. Once the documents are synced, then start a second replicator for the remaining documents .
That said, I am not sure from your use case description if you are looking for prioritization. It looks like you just want document A and B to be available on server before you can do some processing on it on server side. Something you could just query for on server side …

I wouldn’t characterize this as “not a valid solution”. It is a perfectly valid and recommended solution for such use cases and JSON gives the flexibility to nest data in this way but I can understand if you cannot change your data model.