MongoEngine/mongoengine

The created_at and updated_at fields have disappeared.

99Kies opened this issue · 1 comments

Why after setting the created_at and updated_at fields, there is no data associated with the User instance after it is created.
my code:

class User(Document):
    uuid = UUIDField(default=uuid.uuid4, editable=False, unique=True)
    username = EmailField(max_length=100, required=True)
    created_at = DateTimeField(auto_now_add=True)
    updated_at = DateTimeField(auto_now=True)

datagrip:
No created_at and updated_at fields

I need to get the time of created_at and updated_at to compare with the current time.

auto_now and auto_now_add don't exist in MongoEngine...

You can get the created_at easily with created_at = DateTimeField(default=datetime.utcnow) (or by extracting the created timestamp from your primary key if it's an ObjectId) but updated_at, there s currently no built in way.

Dup of #21