15 lines
352 B
TypeScript
15 lines
352 B
TypeScript
export interface EntityProps<Id = string> {
|
|
readonly id: Id;
|
|
}
|
|
|
|
export abstract class Entity<Id> implements EntityProps<Id> {
|
|
protected constructor(readonly id: Id) {}
|
|
|
|
equals(other?: Entity<Id>): boolean {
|
|
return !!other && this.id === other.id;
|
|
}
|
|
}
|
|
|
|
// Alias for backward compatibility
|
|
export type IEntity<Id = string> = EntityProps<Id>;
|