amplify-swift icon indicating copy to clipboard operation
amplify-swift copied to clipboard

Using DataStore with Sync Disabled

Open pstance opened this issue 4 years ago • 14 comments

I would like to use the DataStore and API plugins in my application. Every time I configure the DataStore and API plugins, the sync functionality of DataStore is automatically enabled. Is there a way to configure DataStore without the sync engine and configure the API plugin?

pstance avatar Aug 21 '20 18:08 pstance

Hi, @pstance . Thanks for reaching out, I have two questions:

  1. Do you mean you want DataStore and API work separately in one project (Probably you don't want the automation part between local and remote and want to do that manually)?
  2. The two plugins are sharing one schema or have two different schemas?

please give me more details, thanks

ruiguoamz avatar Aug 21 '20 20:08 ruiguoamz

  1. Yes, I want them to work separately on the same project.
  2. They are sharing the same schema.

pstance avatar Aug 21 '20 21:08 pstance

Hi, @pstance . So we don't support the separate use of DataStore and API especially when sharing one schema in one project because of data consistency problem.

Do you mind tell us why you want them to work separately? We would also treat this as feature request

ruiguoamz avatar Aug 22 '20 01:08 ruiguoamz

Is it possible with two schemas?

pstance avatar Aug 22 '20 03:08 pstance

@pstance Can you describe the use case you're trying to accomplish? There may be a different way of getting to what you want.

palpatim avatar Aug 24 '20 16:08 palpatim

I would like to do this as a workaround to this issue https://github.com/aws-amplify/amplify-js/issues/6034

david-gettins avatar Sep 04 '20 10:09 david-gettins

Hey @david-gettins, turning on/off the cloud sync depending on the network type is indeed an interesting feature. Both that and allowing you to use API and DataStore separately are being considered but at the moment neither are supported.

I believe that implementing your own integration between API and DataStore depending on the network conditions could be quite complex.

I'll keep this issue open so we track it in our backlog and will update you when make progress on it. Thanks for getting in touch with us.

drochetti avatar Oct 10 '20 04:10 drochetti

Also interested in this! Slightly different application (we want to give users the ability to "opt in" on cloud sync, but everything stays local until then). This would be in addition to wifi/cellular.

If this is addressed elsewhere I've failed to find it 🙈 and would appreciate any direction.

jonathanloos avatar Jan 31 '21 22:01 jonathanloos

Is it not possible to use DataStore.stop()/DataStore.start() to control the cloud synchronization? Similar like in this example in the docs: https://docs.amplify.aws/lib/datastore/sync/q/platform/js#reevaluate-expressions-at-runtime

EDIT: Just saw this comment in the docs:

Start

Synchronization starts automatically whenever you run any DataStore operation (query(), save(), delete(), observe().) You can also explicitly begin the process with DataStore.start():

Apparently, sync will be enabled automatically after ever operation. Not sure if a workaround would be to call DataStore.stop() after every operation to prevent sync to the cloud?

jo-fra avatar Feb 02 '21 23:02 jo-fra

Apparently, sync will be enabled automatically after ever operation. Not sure if a workaround would be to call DataStore.stop() after every operation to prevent sync to the cloud?

It would not be a reliable workaround, since the async processes would kick off and at least partially complete before the stop was invoked.

palpatim avatar Feb 08 '21 20:02 palpatim

My problem: Want to use Datastore locally only. No sync. Just a nice little datastore abstracting away the woes of local storage for various platforms.

My (very dirty) solution: I removed Amplify.configure(awsexports) line from my index.tsx. Now I get an explicit warning telling me that my data isn't syncing to the cloud. But that's okay!

Also in the docs, there is this bit which I'm curious how one can go achieve it after completing the Amplify's official tutorial image

ManasN avatar May 18 '21 02:05 ManasN

My problem: Want to use Datastore locally only. No sync. Just a nice little datastore abstracting away the woes of local storage for various platforms.

My (very dirty) solution: I removed Amplify.configure(awsexports) line from my index.tsx. Now I get an explicit warning telling me that my data isn't syncing to the cloud. But that's okay!

Also in the docs, there is this bit which I'm curious how one can go achieve it after completing the Amplify's official tutorial image

Thanks for sharing this, I am currently using this as my work around until I figure out a better solution. I synced my app with the cloud for testing purposes to make sure everything worked as intended but now want to continue development work which includes adding/updating schemas. I cannot find an easy way to just turn it off.

Additionally I'm trying to find a way to conditionally sync users' data to the cloud dependent on whether or not they have a paid subscription. Meaning free users would only be able to store their data locally unless they chose to upgrade to a paid service.

Any help on this would be much appreciated!

jro55 avatar Jun 16 '21 20:06 jro55

My problem: Want to use Datastore locally only. No sync. Just a nice little datastore abstracting away the woes of local storage for various platforms. My (very dirty) solution: I removed Amplify.configure(awsexports) line from my index.tsx. Now I get an explicit warning telling me that my data isn't syncing to the cloud. But that's okay! Also in the docs, there is this bit which I'm curious how one can go achieve it after completing the Amplify's official tutorial image

Thanks for sharing this, I am currently using this as my work around until I figure out a better solution. I synced my app with the cloud for testing purposes to make sure everything worked as intended but now want to continue development work which includes adding/updating schemas. I cannot find an easy way to just turn it off.

Additionally I'm trying to find a way to conditionally sync users' data to the cloud dependent on whether or not they have a paid subscription. Meaning free users would only be able to store their data locally unless they chose to upgrade to a paid service.

Any help on this would be much appreciated!

@jro55 Have you figured it out?

tolik505 avatar Jul 16 '22 10:07 tolik505

Related Issue https://github.com/aws-amplify/amplify-swift/issues/848

lawmicha avatar Aug 10 '23 15:08 lawmicha