【发布时间】:2021-05-24 20:03:36
【问题描述】:
我有这个突变
@Mutation(() => AuthResponse, { nullable: true })
async signUp(
@Ctx() { req }: MyContext,
@Arg("details") details: UsernamePasswordTypes
): Promise<AuthResponse> {
const { password, username } = details;
const user = await User.create({
username,
password: "hasedPassword"
});
try {
await user.save();
req.session.userId = user.id;
console.log("USER CREATED",user)
return {user}
} catch (e) {
return {
errors: [
{
field: "username",
message: "username already taken",
},
],
};
}
}
在这我可以看到USER created
我有两个问题
- 控制台中没有打印密码字段
- 它没有在 postgres db 中保存数据,但它已经创建了用户表
注意:我是第一次运行此代码,所以我想我需要创建表和字段,所以不知道如何创建。如何在 typeorm 中创建迁移?
【问题讨论】:
标签: node.js postgresql typeorm