📄️ Conditional selects
Sometimes you may want to select some fields based on a runtime condition.
📄️ Deduplicate joins
When building dynamic queries, you sometimes end up in situations where the same join
📄️ Dealing with the Type instantiation is excessively deep and possibly infinite error
Kysely uses complex type magic to achieve its type safety. This complexity is sometimes
An Expression is the basic type-safe query building block in Kysely. Pretty much all methods accept expressions as inputs. Most internal classes like SelectQueryBuilder and RawBuilder (the return value of the sql tag) are expressions themselves.
📄️ Extending kysely
In many cases Kysely doesn't provide a built-in type-safe method for a feature. It's often because adding
📄️ Introspecting relation metadata
Extracting metadata about tables and views from your database schema in runtime is possible using the methods in the instrospection property of a Kysely instance.
📄️ Raw SQL
You can execute raw SQL strings and pass raw SQL snippets to pretty much any method or function
Kysely IS NOT an ORM. Kysely DOES NOT have the concept of relations.
📄️ Working with schemas
First of all, when we talk about schemas in this document, we mean custom
📄️ Splitting build, compile and execute code
Kysely is primarily a type-safe sql query builder.