Is there a way to listen or check for specific data synced or not in the mobile app & How do i delete the synced data from the my local db without effecting the cloud data?

  1. Is there a way to listen or check whether local db synced or not in the mobile app?
  2. How do i delete the specific synced data from local db without effecting the cloud data?

You have not specified which language/SDK you’re using, but most SDKs have an API similar to:

await realm.SyncSession.WaitForUploadAsync(); // Ensures local data is uploaded
await realm.SyncSession.WaitForDownloadAsync(); // Ensures remote data is downloaded

Regarding 2. - if you’re using Flexible Sync, you can remove the subscription that covers the data and the local objects will be deleted without affecting the remote ones. For example:

var yearAgo = DateTimeOffset.UtcNow.Add(TimeSpan.FromDays(-365));
realm.Subscriptions.Update(() => {
  // Get all invoices from last year
  realm.Subscriptions.Add(realm.All<Invoice>().Where(i => i.CreatedDate > yearAgo));

await realm.Subscriptions.WaitForSynchronization();

// We now have all invoices from the past year. However the user changes their filter
// preferences to "last month", so we want to remove the local invoices older than a month

var monthAgo = DateTimeOffset.UtcNow.Add(TimeSpan.FromDays(-30));
realm.Subscriptions.Update(() =>
  // Remove all subscriptions on the Invoice class
  realm.Subscriptions.Add(realm.All<Invoice>().Where(i => i.CreatedDate > monthAgo));

await realm.Subscriptions.WaitForSynchronizationAsync();

// Now we've removed the older invoices and are only storing the last 30 days of data.


I am using Flutter SDK

Lets say i want to delete all entries from Invoice i.e., make it empty

Does below code delete all Invoice entries from local db without effecting the remote data?

realm.Subscriptions.Update(() =>
    // Remove all subscriptions on the Invoice class
await realm.Subscriptions.WaitForSynchronizationAsync();

Not exactly - what happens in the code below is (translated into dart):

realm.subscriptions.update((mutableSubscriptions) {
  // removes all Invoice subscriptions - if this was the only operation in
  // the update block, this would leave no Invoice objects on the client.

  // creates a subscription for all invoices.
  mutableSubscriptions.add(realm.all<Invoice>()); //

When the server sees this update, it’ll calculate the difference between what the client was seeing before and what the client should be seeing and will send you the objects that will satisfy the new subscription. Since now you’d be asking for all invoices, the server will send you any Invoice documents that the client previously didn’t have.

If you wanted to remove all invoice entries from the local database, you would only call removeByType<Invoice>.

  1. You mean update function with removeByType will delete all invoice objects from local db and no effect on remote data. Am i correct?

  2. Once i am done with deleting invoice objects from the local db, I wanted to resume the syncing mechanism for newly inserted invoice objects

How do i achive this?

  1. Can i get the sync status for newly inserted object without calling waitfordownloadasync function? I dont want to download data again from cloud cluster. Do we have any other solution

I’m not sure what exactly you’re trying to achieve here. I’ll try to reply to the best of my abilities, but you’re probably going to need to add more details.

  1. Yes, subscriptions are what tells the server which data to send. If you don’t have a subscription for some data, it’ll continue living on the server, but will be removed from the local device.
  2. If you want to get objects that were created after a certain point, you’ll need a subscription that covers them. For example, you could add a subscription for realm.query<Invoice>("createdDate > $0", This will instruct the server to send you newly created objects but not the old ones.
  3. There’s no “per document” sync status. If you want to make sure that all data is uploaded to the server, you need to call realm.syncSession.waitForUpload(). If you want to make sure all data is downloaded, you need waitForDownload().

Let me add more details

  1. I want to wipe out all the local data for every week without affecting the remote data.
  2. Before wiping out, make sure all local data is synced.
  3. Resume syncing mechanism for freshly inserted data

Okay, so then you don’t need to explicitly wait for uploading the data as that will happen naturally as part of sync. So if we go back to our invoices example, let’s say you have something like this:

// First time the user opens the app, subscribe for invoices older than a month
realm.subscriptions.update((mutableSubscriptions) {
  mutableSubscriptions.add(realm.query<Invoice>("createdDate > $0", -30))));

// Now create some invoices
realm.write(() {

// Now you want to remove the local data and only sync new invoices
realm.subscriptions.update((mutableSubscriptions) {
  // Subscribe for new invoices only
  mutableSubscriptions.add(realm.query<Invoice>("createdDate > $0",;

What happens at the end is that you tell the server that you no longer wish to see old invoices and it will send “delete” instructions for all local Invoice objects that were created between now()-30d and now() (without, of course, deleting the documents themselves on the server). It will then continue sending you newly inserted documents. Any objects you have created prior to updating the query will be synchronized with the server, so you won’t lose any data. Finally, if you want a deterministic way of ensuring the changes have been propagated in both directions, you can call await realm.subscriptions.waitForSynchronization() which will complete when local data has been uploaded, the server has sent you all data matching the new subscriptions, and any data that doesn’t match the subscriptions has been removed from the local device.

Thanks for the help @nirinchev1
I will try this solution and give you the update