UniqueEntityID
Defines a unique ID (128 bits - RFC 4122) for an entity
It provides immutable UUID for entity
const id = new UniqueEntityID();
console.log(id);
> UniqueEntityID {value: "e867e8cf-2604-4034-8858-c38da17c4f88"}const id = new UniqueEntityID();
console.log(id.value);
> "e867e8cf-2604-4034-8858-c38da17c4f88"If you provide a value, the id will be created with provided value.
const id = new UniqueEntityID('my_id_value');
console.log(id.value);
> "my_id_value"It has its own method of comparing values.
Use DomainId
all domain entities by default have an id defined by BaseDomainEntity
The argument is optional. If informed, It will be considered as value.
Short ID
If you prefer short ids, you may use ShortDomainId, default 16 bytes
Last updated
Was this helpful?