23 lines
473 B
TypeScript
23 lines
473 B
TypeScript
import { PrimaryKey, Sequelize, Column, Table, Model } from "sequelize-typescript";
|
|
|
|
@Table
|
|
export class Page extends Model {
|
|
@PrimaryKey
|
|
@Column
|
|
public slug: string;
|
|
|
|
@Column
|
|
public title: string;
|
|
}
|
|
|
|
@Table
|
|
export class Exercise extends Model {
|
|
}
|
|
|
|
export async function init(path: string): Promise<Sequelize> {
|
|
let sequelize = new Sequelize(`sqlite:${path}`, {
|
|
models: [Page, Exercise],
|
|
});
|
|
await sequelize.sync({ force: true });
|
|
return sequelize;
|
|
}
|