import { Collection, EntitySchema } from '@mikro-orm/core';
import { Book } from './Book.js';
import { BaseEntity } from './BaseEntity.js';
export class Author extends BaseEntity {
constructor(name, email) {
super();
this.name = name;
this.email = email;
this.books = new Collection(this);
this.createdAt = new Date();
this.updatedAt = new Date();
this.termsAccepted = false;
}
}
export const schema = new EntitySchema({
class: Author,
properties: {
name: { type: 'string' },
email: { type: 'string', unique: true },
age: { type: 'number', nullable: true },
termsAccepted: { type: 'boolean', default: 0, onCreate: () => false },
identities: { type: 'string[]', nullable: true },
born: { type: DateType, nullable: true, length: 3 },
books: { kind: '1:m', entity: () => 'Book', mappedBy: book => book.author },
favouriteBook: { kind: 'm:1', type: 'Book' },
version: { type: 'number', persist: false },
},
});
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4