📄️ Relations
Kysely IS NOT an ORM. Kysely DOES NOT have the concept of relations.
📄️ Reusable helpers
Here's a playground link containing all the code in this recipe.
📄️ Data types
When talking about data types in Kysely we need to make a distinction between the two kinds of types:
📄️ Raw SQL
You can execute raw SQL strings and pass raw SQL snippets to pretty much any method or function
📄️ Splitting query building and execution
Kysely is primarily a type-safe sql query builder.
📄️ Conditional selects
Sometimes you may want to select some fields based on a runtime condition.
📄️ Expressions
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.
📄️ Working with schemas
First of all, when we talk about schemas in this document, we mean custom
📄️ 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
📄️ 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.
📄️ Logging
It is possible to set up logs for all queries using the log property when instantiating Kysely.