#✅ - datastore save() change createdat and updatedat to null
6 messages · Page 1 of 1 (latest)
Timestamp fields are supposed to be updated by the DynamoDB of your backend. When your data mutation gets synced to Cloud, the timestamp values will be synced back to the local database.
If you want to manage timestamp yourself, you can defined them in your model schema to override.
More information see: https://docs.amplify.aws/cli/graphql/data-modeling/#customize-creation-and-update-timestamps
Thanks.
But when I use save() to datastore, the createdAt, and updatedAt are both saved to null; my list builder needs to sort the data by updatedAt before building it, so when the data have no updatedAt, I can't sort it.😭
Are you using offline mode only?
If you override timestamp fields in the model schema, the generated model will include those fields, with which you can assign values to them when creating a record. Can you give it a try?
I know the reason is that the datastore triggers the local datastore by default, and the creaetedAt and updatedAt are managed by amplify, so the local data will get a null value.
I have created another timestamp by myself to fix my issue.😁
✅ - datastore save() change createdat and updatedat to null