UNPKG

@jfln/marvin-db

Version:

biblioteca de objetos para normalizar o acesso a um banco mongo db

29 lines (21 loc) 570 B
import {PrimaryKey, Property, SerializedPrimaryKey} from '@mikro-orm/core' import {ObjectId} from '@mikro-orm/mongodb' export abstract class BaseEntity { @PrimaryKey() _id!: ObjectId @SerializedPrimaryKey() id!: string @Property() guildId: string @Property({onCreate: () => new Date()}) createdAt: Date = new Date() @Property({onUpdate: () => new Date()}) updatedAt: Date = new Date() public setGuildId(guildId: string): this { this.guildId = guildId return this } constructor(guildId: string) { this.guildId = guildId } }