Skip to content

Latest commit

 

History

History
72 lines (54 loc) · 1.55 KB

README.md

File metadata and controls

72 lines (54 loc) · 1.55 KB

DecoDB Lint Tests

DenoDB with decorators.

Installing

TODO

TODO before first release

  • Attributes decorators
  • Relationships decorators
  • Tests
  • Documentation

Documentation

See the WIKI.

Quick start

Defining models

@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>;
}

Creating connection

(async() => {
  const connector = new DenoDB.MySQLConnector({
    ...
  });
  const db = new DenoDB.Database(connector);

  await setupDatabase(db, {
    models: [Article, Comment, User],
  });
  ...
})();