rate/api/src/entities/entity.ts
Yanis Rigaudeau 39ba4856a2
wip
2023-02-05 22:06:48 +01:00

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();
}
}