quaerateum
Version:
Simple typescript ORM for node.js based on data-mapper, unit-of-work and identity-map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JS.
57 lines (40 loc) • 1.29 kB
text/typescript
import { v4 } from 'uuid';
import { Collection, Entity, IEntity, ManyToMany, ManyToOne, OneToOne, PrimaryKey, Property } from '../../lib';
import { Publisher2 } from './Publisher2';
import { Author2 } from './Author2';
import { BookTag2 } from './BookTag2';
import { Test2 } from './Test2';
()
export class Book2 {
({ fieldName: 'uuid_pk', length: 36 })
uuid = v4();
({ default: 'CURRENT_TIMESTAMP(3)', length: 3 })
createdAt = new Date();
({ nullable: true })
title: string;
({ type: 'text', nullable: true })
perex: string;
({ type: 'float', nullable: true })
price: number;
({ type: 'double', nullable: true })
double: number;
({ nullable: true })
meta: Book2Meta;
({ cascade: [] })
author: Author2;
({ cascade: [] })
publisher: Publisher2;
({ cascade: [], mappedBy: 'book' })
test: Test2;
({ entity: () => BookTag2, inversedBy: 'books', cascade: [] })
tags = new Collection<BookTag2>(this);
constructor(title: string, author: Author2) {
this.title = title;
this.author = author;
}
}
export interface Book2 extends IEntity<string> { }
export interface Book2Meta {
category: string;
items: number;
}