41 lines
1.0 KiB
Markdown
41 lines
1.0 KiB
Markdown
# Overview
|
|
|
|
Database is a Lumi plugin that provides:
|
|
|
|
- HikariCP-backed MySQL/PostgreSQL connections.
|
|
- Schema helpers for creating/updating tables and indexes.
|
|
- Raw SQL queries with parameter binding.
|
|
- Lightweight ORM with annotations, fluent query builder, and async support.
|
|
|
|
## Install
|
|
|
|
1. Build the jar with Gradle.
|
|
2. Put the jar into your server plugins folder.
|
|
3. Start the server once to generate `config.yml`.
|
|
|
|
## Accessing the API
|
|
|
|
```java
|
|
import com.andrewkydev.database.DatabaseProvider;
|
|
import com.andrewkydev.database.DatabaseApi;
|
|
|
|
DatabaseApi api = DatabaseProvider.get();
|
|
```
|
|
|
|
## Feature Highlights
|
|
|
|
### Auto ID on insert
|
|
|
|
If an entity uses `@DbId(autoIncrement = true)` and the id value is empty (0 or null),
|
|
`insert()` will fetch generated keys and assign the id back to the object.
|
|
|
|
### Snake case by default
|
|
|
|
If `@DbEntity` and `@DbColumn` names are not set, class and field names are converted to
|
|
snake_case.
|
|
|
|
### Query helpers
|
|
|
|
`findOneWhere`, `deleteWhere`, and `findWhere` with sorting/limit/offset are available
|
|
in the ORM.
|