From 9485b4401afc39a78e3bf44117ec180b76b31146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Koskim=C3=A4ki?= Date: Sun, 24 Mar 2024 09:14:24 +0200 Subject: [PATCH] make it even more clear that table interfaces are not row types --- site/docs/getting-started/_types.mdx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/site/docs/getting-started/_types.mdx b/site/docs/getting-started/_types.mdx index 661270624..a2bde2695 100644 --- a/site/docs/getting-started/_types.mdx +++ b/site/docs/getting-started/_types.mdx @@ -20,6 +20,10 @@ export interface Database { pet: PetTable } +// This interface describes the `person` table to Kysely. Table +// interfaces should only be used in the `Database` type above +// and never as a result type of a query!. See the `Person`, +// `NewPerson` and `PersonUpdate` types below. export interface PersonTable { // Columns that are generated by the database should be marked // using the `Generated` type. This way they are automatically @@ -57,6 +61,9 @@ export interface PersonTable { // 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 export type NewPerson = Insertable export type PersonUpdate = Updateable