kotlin-exposed-patterns

Implements database access patterns with JetBrains Exposed ORM, HikariCP pooling, and Flyway migrations.

Updated Apr 18, 2026
One-click install
npx skills add https://github.com/JohnRebellion/.claude-public --skill kotlin-exposed-patterns-johnrebellion
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: kotlin-exposed-patterns
Source: https://github.com/JohnRebellion/.claude-public/tree/main/claude/skills/kotlin-exposed-patterns
Command: npx skills add https://github.com/JohnRebellion/.claude-public --skill kotlin-exposed-patterns-johnrebellion

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Setting up database access in Kotlin backend services requires coordinating ORM queries, connection pooling, schema migrations, and transaction management, which is error-prone without established patterns. ## Core Features & Use Cases - Exposed DSL and DAO Queries: Write CRUD operations, joins, aggregations, subqueries, pagination, and batch inserts using both query styles. - Production Database Setup: Configure HikariCP connection pooling and run versioned Flyway migrations at application startup. - Repository Pattern and Testing: Decouple business logic behind repository interfaces and test against an in-memory H2 database. - Use Case: When building a Ktor service backed by PostgreSQL, use these patterns to define UUID tables, run migrations, and implement a coroutine-safe user repository with pagination and JSONB columns. ## Quick Start Ask the assistant to set up an Exposed-based user repository with HikariCP pooling, Flyway migrations, and suspend transaction support for a Kotlin project.

Frequently Asked Questions about kotlin-exposed-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write queries with JetBrains Exposed in Kotlin?▼

Exposed offers two styles: the DSL uses Table.selectAll().where { } with type-safe column expressions, while the DAO style uses entity classes like UserEntity.find { } for lifecycle-managed objects. Wrap all operations in newSuspendedTransaction for coroutine safety.

Exposed DSL vs DAO pattern, which should I use?▼

Use the DSL style for simple, direct SQL-like queries and batch operations. Use the DAO style when you need entity lifecycle management, relationships via referrersOn, and object-oriented mutation of rows.

How do I run database migrations with Flyway in Kotlin?▼

Configure Flyway with your JDBC URL and credentials, point it at classpath:db/migration, enable baselineOnMigrate, and call migrate() at application startup before connecting Exposed. Versioned SQL files like V1__create_users.sql define the schema.

Does Exposed support coroutines and suspend functions?▼

Yes, Exposed provides newSuspendedTransaction, which runs database operations on a coroutine-friendly dispatcher so suspend functions can perform atomic queries without blocking threads. Isolation levels can be passed as parameters.

How do I test Exposed repositories without a real database?▼

Connect Exposed to an in-memory H2 database in PostgreSQL compatibility mode, create tables with SchemaUtils.create, and clean rows between tests. This lets repository tests run fast without a live PostgreSQL instance.

How do I store JSON columns in Exposed with PostgreSQL?▼

Register a custom JSONB column type that serializes values with kotlinx.serialization and wraps them in a PGobject. The column can then be declared on any table and marked nullable as needed.