Skip to content

jmaple.db

The SQLAlchemy declarative base and the JMAPObject mixin that every JMAP data model extends.

Base

Bases: DeclarativeBase

Shared SQLAlchemy declarative base. All jmaple + plugin models extend this.

JMAPObject

Standardises the core columns for a JMAP data object.

DataChange

Bases: Base

One row per create/update/destroy event across every capability.

Partitioned by data_type (the JMAP type name — "Note", "Bookmark", "Mailbox" …) so <Type>/changes queries pull only its own events.

id_column

id_column() -> Mapped[str]

ULID primary key — also used as the JMAP Id string.

created_column

created_column() -> Mapped[datetime]

UTCDateTime

Bases: TypeDecorator[datetime]

Stores naive UTC in the DB; always reads back as a tz-aware UTC datetime.

SQLite drops timezone info, so we coerce on load to keep type guarantees consistent regardless of backend.

new_id

new_id() -> str

ULID-encoded string suitable for JMAP Id values.

utcnow

utcnow() -> datetime

UTC-aware datetime.now() — for default column values.