https://github.com/amauryd/decodb
denodb using decorators
https://github.com/amauryd/decodb
decorators deno denodb orm
Last synced: about 2 months ago
JSON representation
denodb using decorators
- Host: GitHub
- URL: https://github.com/amauryd/decodb
- Owner: AmauryD
- License: mit
- Created: 2021-10-10T16:10:31.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-14T17:52:37.000Z (over 4 years ago)
- Last Synced: 2026-04-08T04:07:58.044Z (3 months ago)
- Topics: decorators, deno, denodb, orm
- Language: TypeScript
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DecoDB [](https://github.com/AmauryD/decoDB/actions/workflows/lint.yml) [](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],
});
...
})();
```