DatumEntity class abstract
Base class for all entities managed by Datum.
This abstract class defines the essential properties and methods that
any data model must implement to be compatible with the Datum synchronization
engine. It promotes immutability through the copyWith method and provides
mechanisms for serialization and change detection. It extends Equatable
to provide value-based equality on the entity's id.
- Implementers
Constructors
- DatumEntity()
-
A unique identifier for the entity. Typically a UUID.
Creates a
constDatumEntity.const
Properties
- createdAt → DateTime
-
The time the entity was created.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
no setter
- isDeleted → bool
-
A flag indicating if the entity is soft-deleted. Instead of physically
deleting records, they are marked as deleted to allow the deletion to be
synced to other clients.
no setter
- isRelational → bool
-
Indicates whether this entity supports relationships.
no setter
- modifiedAt → DateTime
-
The last time the entity was modified. This is crucial for conflict
resolution strategies like "last write wins".
no setter
-
props
→ List<
Object?> -
The list of properties that will be used to determine whether
two instances are equal.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stringify → bool?
-
If set to
true, thetoStringmethod will be overridden to output this instance'sprops.no setterinherited - userId → String
-
The ID of the user who owns this entity.
no setter
- version → int
-
The version of the entity, used for optimistic locking and conflict detection.
This number should be incremented on every modification.
no setter
Methods
-
copyWith(
{DateTime? modifiedAt, int? version, bool? isDeleted}) → DatumEntity - Creates a copy of the entity with updated fields.
-
diff(
DatumEntity oldVersion) → Map< String, dynamic> ? -
Compares this entity with an older version and returns a map of the
fields that have changed. Returns
nullif there are no differences. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDatumMap(
{MapTarget target = MapTarget.local}) → Map< String, dynamic> - Serializes the entity to a map.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited