Start document synchronization explicitly

34 views
Skip to first unread message

Marcelo Magnani

unread,
Feb 21, 2019, 1:48:23 PM2/21/19
to MongoDB Stitch Users
Hi guys! I am testing MongoDB mobile sync with Atlas (via Stitch). In my test scenario, I need to store a document in the mobile database only and synchronize just after an explicit action of the user... (a kind of draft behavior)

When I execute "remoteCollection.sync().insertOne(p.toDocument());" the document is immediately sent...

Someone know how can I synchronize a document only when the user does an action explicitly?



Drew DiPalma

unread,
Feb 21, 2019, 1:59:20 PM2/21/19
to MongoDB Stitch Users
Hi Marcelo – 

Currently, Mobile Sync doesn't offer a way to sync on command.  For the above workflow, we would recommend syncing a draft document (either as a separate document or with a field marking it as a draft).   Would this fit your case?  

In the longterm, we are considering some improvements that would streamline this flow and will take your case into account. If you'd like to have somewhere to track this improvement then we suggest filing a request on canny.io.

Thanks,
Drew

Marcelo Magnani

unread,
Feb 22, 2019, 9:43:27 AM2/22/19
to MongoDB Stitch Users
Drew, thanks for your quick answer. We will try with your approach.

Another idea (inclusive useful for other cases in my application) is to use a collection that is not synchronized, like a local collection, but I suspect that will not work because the doc mention: "Your application can use either the remote service (which provides access to both MongoDB Mobile and Atlas) or the local service, but not both at the same time."... 

Do you know if I can use a collection as local and other collection as remote on the same app?

Thanks,
Marcelo Magnani

Drew DiPalma

unread,
Feb 22, 2019, 10:17:12 AM2/22/19
to MongoDB Stitch Users
Hi Marcelo – 

Unfortunately, it's not possible to have both a local and remote collection at this point in the beta.  We are investigating some work that I think will help your case, but I'm not able to share more details at this time.  I can update this thread in a few weeks if that will help.

Thanks,
Drew

Tim Glenn

unread,
Aug 16, 2019, 12:51:06 AM8/16/19
to MongoDB Stitch Users
Hi. I'm in the process of testing out MongoDB Mobile and Stitch and I have a design choice where I want to opt into storing data into Atlas, but my customers will be mostly offline and I want to give them the option to save to Atlas in the future. Will I be able to use the stitch remote collection locally until I allow the sync to occur?
Reply all
Reply to author
Forward
0 new messages