Offline Sync records CreatedAt is null until PushAsync is called and if set directly, is overwritten with the Sync time. #74

Closed
renzska opened this Issue Feb 3, 2016 · 3 comments

Projects

None yet

5 participants

@renzska
renzska commented Feb 3, 2016

In our code, we display records with the date they were created. We are using the CreatedAt field to do this. When switching over to use offline sync, a new local record does not have the CreatedAt field populated until after a PushAsync is called. To address this issue we are setting the CreatedAt value to DateTime.Now; so we have a value in the local DB before the push. In our testing, however, the CreatedAt date is overwritten with the time the sync occurs.

Is it fair to say that the CreatedAt should not be used in this manner? If we want to store the date the user created the record, we would need to store it in our own field? I'm guessing this is the case. It would be good to have this documented somewhere.

@apoorvg
apoorvg commented Feb 12, 2016

We have observed the same behavior and are using our own field to store the record creation time. CreatedAt / UpdatedAt are always updated / overridden post Push.

@nadjibus

+1, could be helpful if we can save CreatedAt to local table, then let the server overrides it when we Sync (to avoid malicious things/invalid device Date/Time)

@lindydonna
Member

@renzska CreatedAt cannot be used in this way. If you need the value of the local created at, you will need to create a new field. You can create it only locally, if you use the JsonIgnore attribute.

@lindydonna lindydonna closed this May 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment