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

Deleting items from the database, filtering non-deleted items on Android (Kotlin) #2393

Open
flying-mojo opened this issue Apr 11, 2023 · 4 comments
Assignees
Labels
feature-request Request a new feature GraphQL API Related to the API (GraphQL) category/plugins transferred This issue was transferred from another Amplify project

Comments

@flying-mojo
Copy link

Which Specific Feature is your question related to?

Data, model generation

Question

Hi! I have two related questions:

  1. is it possible to completely remove/purge all deleted items from my database either via amplify cli or amplify studio? At the moment when i query the database with graphql queries the returned answer includes all the items that have been deleted. Is it possible to completely remove the deleted items from the database so that they do not appear in any queries?

  2. On node.js / javascript the autogenerated model (generated using amplify codegen models) does include a _deleted property that i can check and filter out all the deleted items. However on Android (Kotlin) the generated model does not have _deleted property, so i can not filter out deleted items. How can i filter out deleted items from my list queries on Android/Kotlin?

Thanks,

@flying-mojo flying-mojo added pending-triage Issue is pending triage question General question labels Apr 11, 2023
@ykethan ykethan transferred this issue from aws-amplify/amplify-studio Apr 12, 2023
@ykethan ykethan added the transferred This issue was transferred from another Amplify project label Apr 12, 2023
@mattcreaser mattcreaser self-assigned this Apr 19, 2023
@mattcreaser
Copy link
Member

Hi @flying-mojo - can you please clarify how you're deleting the items? Are you deleting the item through DataStore?

@flying-mojo
Copy link
Author

Hi @mattcreaser !
No, im using the graphql API:
API.graphql(graphqlOperation(deleteOperation,...)
or (on android):
Amplify.API.mutate(ModelMutation.delete(...))
or sometimes manually through Amplify console content tab.

@eeatonaws eeatonaws added GraphQL API Related to the API (GraphQL) category/plugins and removed pending-triage Issue is pending triage labels Apr 21, 2023
@mattcreaser
Copy link
Member

Hey @flying-mojo! Regarding question 1 - it is possible to completely remove deleted items from the underlying datasource which will remove them completely from any response. Here's one way to do this: from Studio you can go to GraphQL API and click on the resource name to open AppSync, then to Data Sources and click on the resource for the particular model to open DynamoDB, Explore Table Items and then select the item and use Actions > Delete Item.

Note that the reason items remain in the table after deletion is to allow other clients an opportunity to sync the deletion. Directly deleting the row could potentially orphan the record in clients that haven't sync'd the delete. You can change the TTL that the record stays in the base table by navigating to the datasource in AppSync as above, and then selecting the datasource and hitting Edit, and changing the value for Base table time to live (TTL in minutes).

I'm still looking in to your second question and will get back to you when I have more information.

@tylerjroach
Copy link
Member

I think a bit of the confusion here is that you are using Amplify API with conflict detection enabled (ex: has _deleted property), which is typically enabled when using DataStore. Are you using DataStore elsewhere and/or is conflict detection important to you? Without it, deleted models would simply be deleted.

This would be a feature request on Amplify API side to filter by deleted. A workaround would be to write a graphql request with a custom query, rather than using the standard ModelQuery.

@tylerjroach tylerjroach added feature-request Request a new feature and removed question General question labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request a new feature GraphQL API Related to the API (GraphQL) category/plugins transferred This issue was transferred from another Amplify project
Projects
None yet
Development

No branches or pull requests

5 participants