I am trying to use d1-orm and the model setup.
I created a model:
new Model(
{
D1Orm: orm,
tableName: 'user_chats',
primaryKeys: 'id',
autoIncrement: 'id',
// uniqueKeys: [['email']],
},
{
id: {
type: DataTypes.INTEGER,
notNull: true,
},
}
)
My expectation is that then, I can infer the type and it'd know that the id field is kind of optional for inserts and stuff like that?
But doing type UserChats = Infer<typeof models.user_chats>
Followed by a definition if said object:
const userChats: UserChats = {
}
Shows the type error:
Property 'id' is missing in type '{ }' but required in type 'InferFromColumns<{ id: { type: DataTypes.INTEGER; notNull: true; };
I'd hoped that this would just work? Am I missing something? Do I have to update my code somehow to be able to use types with that?
I am trying to use d1-orm and the model setup.
I created a model:
My expectation is that then, I can infer the type and it'd know that the
idfield is kind of optional for inserts and stuff like that?But doing
type UserChats = Infer<typeof models.user_chats>Followed by a definition if said object:
Shows the type error:
I'd hoped that this would just work? Am I missing something? Do I have to update my code somehow to be able to use types with that?