kotlin-exposed-patterns

Demonstrate database interaction patterns with JetBrains Exposed ORM in Kotlin.

Updated May 24, 2023
One-click install
npx skills add https://github.com/Kimjiman/basic-arch --skill kotlin-exposed-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-exposed-patterns
Source: https://github.com/Kimjiman/basic-arch/tree/main/.claude/skills/kotlin-exposed-patterns
Command: npx skills add https://github.com/Kimjiman/basic-arch --skill kotlin-exposed-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires org.jetbrains.exposed:exposed-core, org.jetbrains.exposed:exposed-dao, org.jetbrains.exposed:exposed-jdbc, org.jetbrains.exposed:exposed-kotlin-datetime, org.jetbrains.exposed:exposed-json, org.postgresql:postgresql, com.zaxxer:HikariCP, org.flywaydb:flyway-core, org.flywaydb:flyway-database-postgresql, com.h2database:h2, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to efficiently and safely interact with databases using JetBrains Exposed ORM, covering everything from basic queries to production-ready configurations.

Core Features & Use Cases

  • Exposed DSL & DAO: Learn to write queries using both the SQL-like DSL and the object-oriented DAO pattern.
  • Production-Ready Setup: Implement HikariCP for connection pooling and Flyway for database migrations.
  • Repository Pattern: Structure your data access layer for testability and maintainability.
  • Use Case: Integrate this Skill into a new Kotlin backend project to establish a robust, performant, and well-tested database access layer.

Quick Start

Use the kotlin-exposed-patterns skill to create a new user record in the database.

Frequently Asked Questions about kotlin-exposed-patterns

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

FAQPage Schema
How do I set up JetBrains Exposed ORM with HikariCP connection pooling in Kotlin?

Configure HikariCP connection pooling with JetBrains Exposed ORM by initializing the HikariDataSource with your PostgreSQL JDBC URL and passing it to the Database.connect method. This setup establishes a robust, production-ready database access layer that efficiently manages connections.

What's the difference between Exposed DSL and DAO patterns for Kotlin database queries?

Exposed DSL provides a SQL-like syntax for writing type-safe queries, while the DAO pattern offers an object-oriented approach to interact with database records. You can use both patterns to structure your data access layer for better testability and maintainability.

How do I manage database schema migrations with Flyway in a Kotlin Exposed project?

Manage database schema migrations with Flyway by adding the flyway-core and flyway-database-postgresql dependencies to your Kotlin project. Flyway handles database migrations automatically, ensuring schema evolution and data integrity across production environments.

Can I use the Repository pattern with JetBrains Exposed for production database access?

Yes, you can implement the Repository pattern with JetBrains Exposed to structure your data access layer. This approach wraps DSL queries and DAO operations into repository classes, ensuring testability, maintainability, and clear separation of concerns in production environments.

Does JetBrains Exposed ORM support PostgreSQL and H2 databases?

JetBrains Exposed ORM supports both PostgreSQL and H2 databases through JDBC drivers. You include the org.postgresql and com.h2database dependencies to connect Exposed to these databases for transaction management and complex query execution.

How do Kotlin Exposed transactions work for ensuring data integrity?

Exposed transactions wrap your database queries to ensure data integrity by executing DSL queries and DAO operations within a single transactional block. This mechanism guarantees that complex queries and schema modifications either complete successfully or roll back entirely.