我正在尝试按照此React GraphQL TypeScript 教程进行编码
该项目使用 MikroOrm 与 PostgreSQL 数据库进行通信。
目标:创建一个 post 实例并将其插入数据库。
目前我在 19.53 分钟,遇到了以下错误,该错误没有出现在视频中,我不知道为什么。
Post.ts 文件:
@Entity() //correspond to database table.
export class Post {
@PrimaryKey()
id!: number;
@Property({ type: 'date'}) //denote database column, without it its just a class attribute
createdAt = new Date();
@Property({ type: 'date', onUpdate: () => new Date() })
updatedAt = new Date();
@Property({type: 'text'})
title!: string;
}
Run Code Online (Sandbox Code Playgroud)
Index.ts 文件:
const main = async () => {
const orm = await MikroORM.init(microConfig);
const …Run Code Online (Sandbox Code Playgroud)