【发布时间】:2019-12-27 04:19:08
【问题描述】:
使用 postgres 数据库,我能够连接到数据库,但是即使按照教程一步一步地创建 user.entity.ts 文件(下面的代码),数据库中的任何内容都不会发生变化。
据我所知,postgres/typeorm 已正确安装最新版本。
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
@Entity()
export class Users {
@PrimaryGeneratedColumn('uuid')
id: number
@Column({
length: 50
})
firstName: string;
}
这里是 ormconfig.json
{
"type": "postgres",
"host": "localhost",
"port": "5432",
"username": "postgres",
"password": "pw",
"database": "metabook",
"synchronise": true,
"logging": true,
"entities": ["./dist/**/*.entity{.ts,.js}"]
}
应该添加带有 2 列(id 和 firstName)的“用户”表。在控制台中,在 ormconfig.json 中设置为 true 的日志记录应该显示正在运行的 sql 查询以创建表,但除了成功运行应用程序之外什么都没有发生(输出如下)。
Expected output from tutorial video
有人知道我是否遗漏了什么吗?
【问题讨论】:
-
我认为键值是
synchronize对吧? -
您完全正确。太习惯英式拼写了,谢谢指出!现在按预期工作
标签: postgresql typescript config nestjs typeorm