Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/amauryd/decodb

denodb using decorators
https://github.com/amauryd/decodb

decorators deno denodb orm

Last synced: 5 days ago
JSON representation

denodb using decorators

Awesome Lists containing this project

README

        

# DecoDB [![Lint](https://github.com/AmauryD/decoDB/actions/workflows/lint.yml/badge.svg)](https://github.com/AmauryD/decoDB/actions/workflows/lint.yml) [![Tests](https://github.com/AmauryD/decoDB/actions/workflows/tests.yml/badge.svg)](https://github.com/AmauryD/decoDB/actions/workflows/tests.yml)

[DenoDB](https://github.com/eveningkid/denodb) with decorators.

## Installing

TODO

## TODO before first release

- [x] Attributes decorators
- [x] Relationships decorators
- [ ] Tests
- [ ] Documentation

## Documentation

See the [WIKI](https://github.com/AmauryD/decodb/wiki).

## Quick start

### Defining models

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

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

### Creating connection

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

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