Skip to content

AmauryD/decodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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],
  });
  ...
})();

Releases

No releases published

Packages

No packages published