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

feat(datastore): Add DataBase Name Provider as optional parameter on DataStore plugin initializer #2808

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

baldarama
Copy link

@baldarama baldarama commented Mar 11, 2023

Issue #

Description

this changes will allow developers to specify a name for the DataStore database file, this is needed in apps that allow multiple users one at at time.

app is configured with a sync expression that syncs all records of a user based in his "accountId"
each user has a unique "accountId"
the app can be used by multiple users one at a time

scenario
there are 2 users User a and User b

  1. User a logs in
  2. data store is synced
  3. User a logs out
  4. User b logs in
  5. data store is synced

in the above scenario user b records will not be synced, only the changes that happened between the time user a logged out and user b logged in will be synced, user b may be able to see user a records.

solution 1 (this is not a good solution but it is what can be done before changes on this pr)
clear data store before sync when it is detected that a different user has logged in

solution 2 (only possible with the changes in this pr)
specify datastore database name in a way that each user has its own database file.

General Checklist

  • Added new tests to cover change, if needed
  • Build succeeds with all target using Swift Package Manager
  • All unit tests pass
  • All integration tests pass
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)
  • Documentation update for the change if required
  • PR title conforms to conventional commit style
  • New or updated tests include Given When Then inline code documentation and are named accordingly testThing_condition_expectation()
  • If breaking change, documentation/changelog update with migration instructions

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@baldarama baldarama requested a review from a team as a code owner March 11, 2023 17:43
BalaramCV added 2 commits March 11, 2023 11:59
…ding-DataStore-database-custom-naming

# Conflicts solved:
#	AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/AWSDataStorePlugin.swift
@baldarama baldarama changed the title added databaseName provider as optional parameter on DataStore plugin initializer added databaseNameProvider as optional parameter on DataStore plugin initializer Mar 11, 2023
@baldarama baldarama changed the title added databaseNameProvider as optional parameter on DataStore plugin initializer feat(datastore): Add DataBase Name Provide as optional parameter on DataStore plugin initializer Jul 20, 2023
@baldarama baldarama changed the title feat(datastore): Add DataBase Name Provide as optional parameter on DataStore plugin initializer feat(datastore): Add DataBase Name Provider as optional parameter on DataStore plugin initializer Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant