MongoEngine / MongoEngine/mongoengine

Make ComplexDateTimeField useable as a TTL index

Open
#928 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting Response Enhancement
Dominant language
Python
Stars
4.3k
Forks
1.2k
Avg merge
4h 41m
Merged PRs (30d)
11

Description

Currently, ComplexDateTimeField is not useable as a TTL index. Right now, this is stored as a simple string to enable lexicographic comparison but MongoDB itself won't be able to use it for a TTL index. I think changing the storage to an array will do the trick:

[ISODate, microsecond]  # zero out seconds/milliseconds in ISODate

This should sort properly and work with MongoDB TTL indexes per the documentation:

http://docs.mongodb.org/manual/core/index-ttl/

Backwards compatibility can be maintained by just converting data on egress to DB.

Thoughts? If everyone agrees this would be a good course, I can work on the PR.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the ComplexDateTimeField implementation and its serialization and deserialization entry points. Read the linked MongoDB TTL index documentation and verify how array storage, ordering, and legacy values would behave. Done means the storage change preserves ordering, supports TTL indexes, and maintains backward compatibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.