使用 NestJS 和 TypeOrm,在我 运行 NestJS 应用程序后不会自动创建表
Using NestJS and TypeOrm, the tables are not being created automatically after I run the NestJS application
使用 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)的 'users' table。在控制台中,日志记录在 ormconfig.json 中设置为 true,应该显示 sql 查询正在 运行 创建 table,但除了成功之外没有任何反应运行 应用程序(输出如下)。
Output
Expected output from tutorial video
有人知道我是否遗漏了什么吗?
正如@Jay McDoniel 指出的那样,synchronize 应该拼写为 z 而不是 s...(同步)
使用 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)的 'users' table。在控制台中,日志记录在 ormconfig.json 中设置为 true,应该显示 sql 查询正在 运行 创建 table,但除了成功之外没有任何反应运行 应用程序(输出如下)。
Output
Expected output from tutorial video
有人知道我是否遗漏了什么吗?
正如@Jay McDoniel 指出的那样,synchronize 应该拼写为 z 而不是 s...(同步)