如何告诉 kysely key-gen 在映射数据库表时使用原始数据类型

问题描述 投票:0回答:1

我正在使用 kysely-codegen 从数据库生成所有模型,但我看到了一个奇怪的行为,它在任何字段上添加

Generated
类型,为什么不生成
number
boolean
仅?

有人知道是否可以防止这种情况吗?

export interface MyTable {
  id: Generated<Numeric>
  otherColumn: Generated<boolean>
typescript kysely
1个回答
0
投票

发生这种情况可能是因为您的表是这样定义的。如果没有,请考虑在

kysely-codegen
项目中创建问题。否则,请查阅文档此处,特别是以下部分:

// You should not use the table schema interfaces directly. Instead, you should
// use the `Selectable`, `Insertable` and `Updateable` wrappers. These wrappers
// make sure that the correct types are used in each operation.
//
// Most of the time you should trust the type inference and not use explicit
// types at all. These types can be useful when typing function arguments.
export type Person = Selectable<PersonTable>
export type NewPerson = Insertable<PersonTable>
export type PersonUpdate = Updateable<PersonTable>
© www.soinside.com 2019 - 2024. All rights reserved.