flamingo icon indicating copy to clipboard operation
flamingo copied to clipboard

Saving existing model object updates createdAt field

Open vladaman opened this issue 4 years ago • 0 comments

Every time we save model it also updates createdAt and updatedAt field. We'd expect the createdAt field would not be updated for future object updates.

Code sample:

final batch = Batch()
..save(existingObject);
await batch.commit();

We can use Batch()..update() but the behavior is different. It will update just updatedAt field but on the device it will set createdAt field to null. Is this expected behavior?

final batch = Batch()
  ..update(existingObject);
  await batch.commit();
  debugPrint("New Val: ${existingObject.createdAt}"); // here createdAt is null

We believe the issue is here, where createdAt will be set to null: https://github.com/hukusuke1007/flamingo/blob/af8836dfeddb4055a5e414bba3b1c63d18cc29be/flamingo/lib/src/model/document.dart#L144

vladaman avatar Dec 05 '21 20:12 vladaman