DenoDB with decorators.
TODO
- Attributes decorators
- Relationships decorators
- Tests
- Documentation
See the WIKI.
@Entity("articles")
export class Article extends DenoDB.Model {
@PrimaryColumn({ type: DenoDB.DataTypes.INTEGER, autoIncrement: true })
declare public id: number;
@Column({
type: DenoDB.DataTypes.STRING,
default: "bonjour",
allowNull: true,
unique: true,
})
declare public name: string;
declare public static comments: () => Promise<Comment[]>;
}
@Entity("comments")
export class Comment extends DenoDB.Model {
@PrimaryColumn(DenoDB.DataTypes.INTEGER)
declare public id: number;
@Column({
type: DenoDB.DataTypes.STRING,
})
declare public content: string;
@BelongsTo(() => Article, "comments")
declare public static article: () => Promise<Article>;
}
(async() => {
const connector = new DenoDB.MySQLConnector({
...
});
const db = new DenoDB.Database(connector);
await setupDatabase(db, {
models: [Article, Comment, User],
});
...
})();