-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 unable to work. #4535
Comments
Do you have an |
Yes. It includes |
For your step #2 above:
How did you do this? Was it with |
i tried both |
It sounds like you don't have a syncable API setup. Can you do the following:
|
Ok, now i got no error from here but the new Post still does not appear in the dynamoDB. Here's the source code for testing
|
Ok, i got it to work after I move the trigger to Here's the source code for testing
|
@ykbryan great to hear! Is there anything in the docs that we could improve that would've made this easier for you? |
Thanks @ykbryan I've added this as a backlog item in the CLI repo |
I ran into this issue when adding DataStore to an existing API. Ultimately I needed to run
|
Hey @kevinold I'm getting the same error here, missing _version _deleted and _lastChangedAt. What did you set the conflict resolution to to fix it ? |
@rakannimer I selected optimistic concurrency per the conflict resolution docs on the DataStore page. Do that and run I will also add the note here that I've filed an issue with being able fully use the DataStore after upgrading the API. That issue is being tracked here: #4588 |
Thanks for the reply ! It did not work for my case, I'll try to setup a simple repro and maybe open another issue, or I'll stick to using vanilla GraphQL. |
@kevinold thanks, this worked in my case |
@undefobj I think the point missed for the case of @ykbryan was that, since this is a functional React component, it should mention that invoking DataStore should be either within a The React component lifecycle should be respected. |
Running |
DataStore.save does not like to save the first record. For me, this saves 1 record:
|
@kevinold your advice/trick did work for my fresh/new project. I can't believe they didn't mention this issue in documentation with the trick. Thank god I found this page. But it also created 2 different tables in Dynamodb(cloud) for same Todo type. Following are names for both tables
And every data from Todo table is replicated into the Amplify-Datastore table. |
You could also add this you the transform.conf.json directly: This information must be included to the documentation! It's pretty hard to guess... Or "@versioned" should generate it. |
Same thing for me in a Quasar project. I have a form that triggers a Datastore.save() and the first entry gets saved locally but not in the DynamoDB. From second on onwards they all get saved properly. Why is the first one not being synced to the backend? |
@cnwork could you open up a new issue with all the details of your project setup |
@cnwork @undefobj @ykbryan I also am having the same issue as you are and I put the function call in an onClick handler as well but still am getting the issue of the first record not being saved an all future ones being saved. |
Hi :) I'm experiencing the same issue of the first object not being synced upon a DataStore.save(). Subsequent DataStore.save()'s correctly sync. Both first and subsequent objects are correctly saved to local storage (in this case, my browser's indexedDb). I am executing these saves within a click handler. This happens in both mock environment, and cloud using the auto-generated schema (Blog, Post, Comment) from amplify api add using authentication as API key. It seems like the first save() method does some kind of initialization without synchronizing that object, but allows subsequent saves to work correctly. When additional saves are made in other handlers, they work correctly. So it's the first save after initializing. Let me know if more info is needed. |
Fixed the issue with: |
Do you have a link to your repo/source code that does this? |
So once I updated via amplify-cli |
Just a warning: don't forget to update your models when adding the Datastore, otherwise you get errors saying that version doesn't exist (because your models need to be updated) I skip the model update so get the error, need to run again amplify update API to take care of my models, below an example from the todolist example You select interactively which models to update (all of them), then your schema.graphql (if you use graphql) will have all the necessary to run flawlessly And as IssacTrvino mention: think in advance if you will use DataStore, because if you add later, you need to clean the table and reinsert all of the items again |
I am using yarn. any suggestions. |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Describe the bug
Unable to get DataStore save data.
To Reproduce
Steps to reproduce the behavior:
create-react-app newapp
amplify codegen models
amplify push
and wait for it to finishonCreatePost
yarn start
and the error:
Expected behavior
DataStore and new Post should be created.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment
Smartphone (please complete the following information):
Additional context
Sample code
You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app.
The text was updated successfully, but these errors were encountered: