18 lines
461 B
TypeScript
18 lines
461 B
TypeScript
import { EntityCtor, EntityInfo } from '@core';
|
|
import { randomUUID } from 'crypto';
|
|
import { ObjectId } from 'mongodb';
|
|
|
|
export class Entity implements EntityInfo {
|
|
_id: ObjectId;
|
|
uuid: string;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
|
|
constructor(raw: EntityCtor) {
|
|
this._id = raw._id || new ObjectId();
|
|
this.uuid = raw.uuid || randomUUID();
|
|
this.createdAt = raw.createdAt || new Date();
|
|
this.updatedAt = raw.updatedAt || new Date();
|
|
}
|
|
}
|