Closed linas-ipxo closed 6 months ago
Hey 👋
This is a documentation issue - PR's welcome.
findPersonById
should accept bigint
or even number | bigint
.insertId
is not undefined
, you can add a non-null assertion as follows: return await findPersonById(insertId!)
Okay, but then person is defined as
export interface PersonTable {
// Columns that are generated by the database should be marked
// using the `Generated` type. This way they are automatically
// made optional in inserts and updates.
id: Generated<number>
...
and the Person
interface doesn't accept bigint
in other parts of the examples. I can change everything to bigint
, but shouldn't the executeTakeFirstOrThrow()
function return insertId
typed based on the interface (number
)? and not bigint
?
We don't know which property is the auto incrementing primary key. All Kysely sees is the table interface and there's no indication of the primary key. Some tables don't even have it or they have a composite primary key.
Bigint is used because it can hold any integer value, unlike number
.
You can easily cast the type using Number(insertId!)
I fixed the getting started guide.
Hello.
Direct copying examples from https://kysely.dev/docs/getting-started?dialect=mysql produces a type error in createPerson():
I obviously can work around this, but as a bit of a newcomer, I'm not exactly sure if this is intented, or is this a bug somewhere.