【问题标题】:postgres sql database Column value is [null]postgresql 数据库列值为 [null]
【发布时间】:2021-12-12 10:39:44
【问题描述】:

我正在使用nestjs & typeorm 来查询

//this is my model(interface)
    export interface Product {
        id?:number,
        
        name?:string,
    }

这是我的 entity.ts

@Entity('product')
export class ProductEntity{
    @PrimaryGeneratedColumn()
    id:number;

    @Column({ type:'text',nullable:true })
    name:string;

    @Column({type:'timestamp',default:() => 'CURRENT_TIMESTAMP'})
    createdAt:Date;

}

name 列值为 Null

这就是我所说的使用 postgress,

有人知道如何解决这个问题吗?

【问题讨论】:

  • 修复什么?如果有 NULL 值,您将在结果中得到它们。您可以通过将列定义为不可为空来防止这种情况发生。
  • i.stack.imgur.com/aYyzy.png ,我发送带有 'name' 值的 post 请求,但它没有保存它。
  • 抱歉,您的问题还不清楚。

标签: database postgresql null nestjs typeorm


【解决方案1】:

您正在向后端发送文本负载。它应该是 JSON 有效负载。 使用下拉菜单选择JSON,问题就会消失。

【讨论】:

    猜你喜欢
    • 2016-08-18
    • 2019-02-22
    • 2011-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-15
    • 2014-10-29
    • 2011-01-19
    相关资源
    最近更新 更多