Kysely

K

Kysely

First came Kysely, the type-safe query builder for TypeScript, then came people asking questions, then came the Discord server.Join if you like Kysely or have questions, or both.

Join

help

query-showcase

announcements

Hydra Modeler - new npm package

It’s not a huge thing, but might be useful for somebody 🙂 I’ve just published Hydra-Modeler to npm — a small, zero-dependency library for transforming flat SQL results into nested JSON trees with associations (belongsTo, hasOne, hasMany, belongsToMany). Works nicely alongside Kysely with hydration + column helpers. 🔗 https://www.npmjs.com/package/hydra-modeler...

A pagination helper

```ts import { sql, type SelectQueryBuilder, type StringReference } from 'kysely'; export async function paginateQuery<DB, TB extends keyof DB, O>( query: SelectQueryBuilder<DB, TB, O>,...

Select count?

Can't find any docs regarding this can someone send me the docs for this? Thank you in advance.

how to sort `db.updateTable` returning values?

``` await db .updateTable("users") .where("id", "in", ({ selectFrom }) => selectFrom("users")...

Prediction league leaderboard

Hey, hope I'm not becoming annoying, but I thought I'd share another query I made, perhaps someone can find it useful. This is a leaderboard for a prediction league. It's using 2 CTEs. In the first one we count occurences where the user predicted the correct result, outcome or first scorer of the match. In the second one we sum and multiply these occurrences by score factor, to distribute points with the following score system: - 1 point for guessing the correct outcome...

CTE with exists() and case()

Hey guys, just wrote this one and I thought I'd share. ```sql WITH "ongoing" AS (...

sale representative performance for Q3 2015

please share your solutions or discuss the solutions in the comments. Kysely feedback and suggestions for enhancement are also welcome....
No description

olympic gold medals

query https://user-images.githubusercontent.com/103982094/211247985-7d15da7b-820f-4615-810b-bd317f3acc13.png please share your solutions or discuss the solutions in the comments. Kysely feedback and suggestions for enhancement are also welcome....

duplicate job listings

query https://user-images.githubusercontent.com/103982094/211246010-ea3cf036-1973-4a69-b2da-57ecc51737a3.png please share your solutions or discuss the solutions in the comments. Kysely feedback and suggestions for enhancement are also welcome....

stock trade

query https://user-images.githubusercontent.com/103982094/228803165-415ff305-d8d7-49e2-ba93-1359bf69c74f.png please share your solutions or discuss the solutions in the comments. Kysely feedback and suggestions for enhancement are also welcome....