Closed CYPH4R closed 2 years ago
Hi @CYPH4R
This is the behavior of the DeafultModel
. It assumes that you want to have both CreatedAt
and UpdatedAt
fields and set the CreatedAt
field when creating a new model (by calling the Create
method on the collection).
Do you want the same behavior in your models?
Issue: when calling Update() on a collection, null values get written as per JSON/BSON convention, but the update method only handles the UpdatedAt field. As such CreatedAt gets set to
0001-01-01T00:00:00.000+00:00
Fix: set CreatedAt struct flag to omitempty, so that there is no need to extend the Update method.
If this is intended behaviour please let me know and I would love to hear why.