我正在使用 kysely-codegen 从数据库生成所有模型,但我看到了一个奇怪的行为,它在任何字段上添加
Generated
类型,为什么不生成 number
或 boolean
仅?
有人知道是否可以防止这种情况吗?
export interface MyTable {
id: Generated<Numeric>
otherColumn: Generated<boolean>
发生这种情况可能是因为您的表是这样定义的。如果没有,请考虑在
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>