amplify-swift
amplify-swift copied to clipboard
Allow for multiple instances of Amplify DataStore
Is your feature request related to a problem? Please describe. Feature request to utilize the DataStore implementation (even just locally) in multiple instances in an application. Currently internal decisions (like datastore name based on bundleId) make this difficult.
Describe the solution you'd like Ability to give datastore an identifier (perhaps defaulted to the appId configured for the amplify instance?)
Describe alternatives you've considered Even bundling multiple instances in different frameworks doesn't get around filesystem issues like the datastore naming.
Hi @johnm555. The Amplify architecture defines that installed plugins are used through the category facade (i.e. Amplify.DataStore
, Amplify.Storage
, etc). Therefore, having multiple instances of a plugin is not really supported and not a feature we're currently evaluating.
That being said, I would like to understand your use case. Maybe there's another way, or even another feature in our roadmap that could help you achieve the same goal. If you're able to provide us more info about what you're trying to achieve, I would be happy to assist you.
Our application supports many different independent feature sets and in order to help us scale some development & operations, we feel that at times it would be easier to have different DataStores (even if that means accessing it outside of the Amplify.DataStore shorthands and configuring/accessing plugins explicitly. Things like the datastore path being based on the bundleId make this difficult.
@johnm555 thanks for the follow up. Even if we allow the datastore path to be customized, using DataStore straight from the plugin class isn't something we recommend or even plan to support. The Amplify.DataStore
is the only entry point we can guarantee that won't break in future releases - not without a proper deprecation plan in place.
That makes sense. What about supporting an application that would have two different frameworks with their own integrations with Amplify datastore?
Another extremely related issue is that it seems the dataStore configuration does not allow which apiName to specify if multiple APIs are configured.
That makes sense. What about supporting an application that would have two different frameworks with their own integrations with Amplify datastore?
Not sure I understand, what do you mean by "two different frameworks with their own integrations"?
Another extremely related issue is that it seems the dataStore configuration does not allow which apiName to specify if multiple APIs are configured.
This is good feedback, thanks! Do you mind creating another feature request with this? You can create a new issue from your comment by clicking the 3 dots and "reference in a new issue".
This issue is stale because it has been open for 14 days with no activity. Please, provide an update or it will be automatically closed in 7 days.
Multiple instances of DataStore is quite a heavy lift that requires a lot of testing to ensure it is still performant, especially performing multiple sync processes on DataStore.start(). See https://github.com/aws-amplify/amplify-swift/issues/2723#issuecomment-1412455546 comment. I don't think we have any future plans in taking on this feature request. Please let us know if you are still blocked on your development since it's been a few years now, and we can explore workarounds.