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.
42 lines (30 loc) • 882 B
text/typescript
import { ObjectID } from 'mongodb';
import { Collection, Entity, ManyToMany, OneToMany, PrimaryKey, Property, IEntity, BeforeCreate } from '../../lib';
import { Book } from './Book';
import { Test } from './test.model';
()
export class Publisher {
()
_id: ObjectID;
()
name: string;
({ entity: () => Book.name, fk: 'publisher' })
books = new Collection<Book>(this);
({ entity: () => Test.name, owner: true })
tests = new Collection<Test>(this);
()
type: PublisherType = PublisherType.LOCAL;
constructor(name: string = 'asd', type: PublisherType = PublisherType.LOCAL) {
this.name = name;
this.type = type;
}
()
beforeCreate() {
// do sth
}
}
export interface Publisher extends IEntity { }
export enum PublisherType {
LOCAL = 'local',
GLOBAL = 'global',
}