Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datastore - Selective Sync #298

Closed
nithin-seenivasan opened this issue Jan 7, 2021 · 15 comments
Closed

Datastore - Selective Sync #298

nithin-seenivasan opened this issue Jan 7, 2021 · 15 comments
Assignees
Labels
datastore Issues related to the DataStore Category feature-request A request for a new feature or an enhancement to an existing API or category.

Comments

@nithin-seenivasan
Copy link

nithin-seenivasan commented Jan 7, 2021

Would be great to have selective sync for Flutter, similar to what exists in Amplify JS. https://docs.amplify.aws/lib/datastore/sync/q/platform/js#selectively-syncing-a-subset-of-your-data

I would ideally like to have a proper control over the syncing process. Ideas could include:

  1. Configure a time interval for a sync to happen
  2. The client can trigger a sync operation
    3. The sync can be on listening to any changes to the datasource like DynamoDB (resolved using Appsync)

Related to issue #297
Also discussed on #5

@haverchuck haverchuck added datastore Issues related to the DataStore Category feature-request A request for a new feature or an enhancement to an existing API or category. labels Jan 7, 2021
@nithin-seenivasan
Copy link
Author

Updated the post above to reflect current status.

@apolo92
Copy link

apolo92 commented Mar 16, 2021

Is there any forecast of when this new functionality will be available?
If we don't have this functionality, is there any way to control the synchronization? By default I understand that it will synchronize the entire cloud DB locally. Does this mean that user A will have user B data on his local device?

@cto-leaps
Copy link

Any idea when selective sync will be available?

@seyaobey
Copy link

This is indeed a much needed feature. Amplify is an amazing product. But I have switched to another platform for my real-time database since for privacy reasons, I cannot download the whole database into every device.

@apolo92
Copy link

apolo92 commented Mar 23, 2021

This is indeed a much needed feature. Amplify is an amazing product. But I have switched to another platform for my real-time database since for privacy reasons, I cannot download the whole database into every device.

What platform have you used to replace datastore? firebase?

@nithin-seenivasan
Copy link
Author

Is there any forecast of when this new functionality will be available?
If we don't have this functionality, is there any way to control the synchronization? By default I understand that it will synchronize the entire cloud DB locally. Does this mean that user A will have user B data on his local device?

Not really, Datastore uses Appsync, and user A will only get the data synced that they are 'subscribed' to. So even though the underlying DynamoDB table is common, the userdata will be separate with no possibility of data leaking between accounts.

@kjones
Copy link

kjones commented Mar 23, 2021

Not really, Datastore uses Appsync, and user A will only get the data synced that they are 'subscribed' to. So even though the underlying DynamoDB table is common, the userdata will be separate with no possibility of data leaking between accounts.

This isn't true by default. You have to explicitly add authorization rules to your GraphQL schema to control what gets synced. The default is everything in the table.

@nithin-seenivasan
Copy link
Author

Not really, Datastore uses Appsync, and user A will only get the data synced that they are 'subscribed' to. So even though the underlying DynamoDB table is common, the userdata will be separate with no possibility of data leaking between accounts.

This isn't true by default. You have to explicitly add authorization rules to your GraphQL schema to control what gets synced. The default is everything in the table.

You are right, @kjones , I forgot that one had to explicitly control what gets synced in the schema. That should solve @apolo92 's issue.

@kjones
Copy link

kjones commented Mar 23, 2021

I'm more interested in selective sync from a performance and cost perspective. Say the table has millions of records and I have auth rules set up. I don't see how AppSync can optimize this query given that all items in the table are only unique by ID. It must do a DynamoDB scan operation on this table and then filter the results by owner. At most it can add a filter expression to the query which still scans the entire table but returns a result set with only the owner's records. With selective sync I should be able to create a GSI on the table and then use a query expression that turns the table scan into an optimized query for the user's data.

@apolo92
Copy link

apolo92 commented Mar 29, 2021

Not really, Datastore uses Appsync, and user A will only get the data synced that they are 'subscribed' to. So even though the underlying DynamoDB table is common, the userdata will be separate with no possibility of data leaking between accounts.

This isn't true by default. You have to explicitly add authorization rules to your GraphQL schema to control what gets synced. The default is everything in the table.

You are right, @kjones , I forgot that one had to explicitly control what gets synced in the schema. That should solve @apolo92 's issue.

Thanks @nithin-seenivasan and @kjones I use @owner permissions in appsync and only sync data user. But during testing I have seen that the Amplify.Datastore.clear () does not work on ios. This command do not nothing :(. Do you have any issue on this topic?

@kjones
Copy link

kjones commented Mar 29, 2021

DataStore.clear() does not work on ios

If this means it doesn't actually clear the local data then I'm of no help.

I have noticed inconsistencies between iOS and Android after the clear() call.

  • DataStore does not have a start()/stop() API like the underlying Android and iOS SDKs so you have to do a throw-away query() to get DataStore() going again.
  • Android seems to restart DataStore immediately without the throw-away query to get it going again. This may not still be true and I may be thinking of earlier days pre-2021.
  • On iOS, observe() stops working after a clear(). There is a fix for this but it hasn't been released yet.

@rajd90
Copy link

rajd90 commented May 15, 2021

i really need this feature as well. selective sync is critical for performance & cost reasons, as we really need to avoid doing scans and use query (as indicated in the many dynamodb best practice examples). is it already possible and just not documented?

@cshfang cshfang self-assigned this May 25, 2021
@rajd90
Copy link

rajd90 commented May 31, 2021

is there any update / timeline on this issue?

@cshfang
Copy link
Member

cshfang commented Jun 1, 2021

is there any update / timeline on this issue?

Thanks all for your valued feedback on this feature. I am unable to provide anything close to concrete dates at this time but it is something we are investigating.

@cshfang
Copy link
Member

cshfang commented Jul 28, 2021

As of v0.2.1, Amplify Flutter should now support selective sync. More information about this can be found in the Amplify Docs here.

@cshfang cshfang closed this as completed Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datastore Issues related to the DataStore Category feature-request A request for a new feature or an enhancement to an existing API or category.
Projects
None yet
Development

No branches or pull requests

8 participants