hukusuke1007 / flamingo

[Flutter Library] Flamingo is a firebase firestore model framework library. 🐤
https://pub.dev/packages/flamingo
MIT License
118 stars 20 forks source link

Saving existing model object updates createdAt field #39

Open vladaman opened 2 years ago

vladaman commented 2 years ago

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