UNPKG

typescript-express-starter

Version:
17 lines (12 loc) 397 B
import { PrimaryKey, Property, SerializedPrimaryKey } from '@mikro-orm/core'; import { ObjectId } from '@mikro-orm/mongodb'; export abstract class BaseEntity { @PrimaryKey() _id!: ObjectId; @SerializedPrimaryKey({ type: 'text' }) id!: string; @Property({ type: 'date' }) createdAt = new Date(); @Property({ type: 'date', onUpdate: () => new Date() }) updatedAt = new Date(); }