Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amauryd/decodb
denodb using decorators
https://github.com/amauryd/decodb
decorators deno denodb orm
Last synced: 17 days 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 (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-14T17:52:37.000Z (about 3 years ago)
- Last Synced: 2024-10-15T13:25:57.838Z (about 1 month ago)
- Topics: decorators, deno, denodb, orm
- Language: TypeScript
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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],
});
...
})();
```