mirror of
https://github.com/maxkratz/edgedb-java.git
synced 2024-09-07 20:33:03 +00:00
parent
b9ddbbbb55
commit
4b9e57e040
2 changed files with 113 additions and 3 deletions
116
README.md
116
README.md
|
@ -1,5 +1,115 @@
|
|||
# EdgeDB Java Binding
|
||||
![EdgeDB Java](./branding/banner.png)
|
||||
|
||||
🏗️ This binding is still WIP and is not yet ready 🏗️
|
||||
<div align="center">
|
||||
<h1>☕ The official Java/JVM client library for EdgeDB ☕</h1>
|
||||
|
||||
Feel free to browse the code and test it out early, no API is finalized yet and could change.
|
||||
<a href="https://github.com/edgedb/edgedb-java/actions" rel="nofollow">
|
||||
<img src="https://github.com/edgedb/edgedb-java/actions/workflows/gradle.yml/badge.svg?event=push&branch=master" alt="Build status">
|
||||
</a>
|
||||
<a href="https://github.com/edgedb/edgedb/blob/master/LICENSE">
|
||||
<img src="https://img.shields.io/badge/license-Apache%202.0-blue" />
|
||||
</a>
|
||||
<a href="https://discord.gg/edgedb">
|
||||
<img src="https://discord.com/api/guilds/841451783728529451/widget.png" alt="Discord">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
## Installation
|
||||
|
||||
The Java binding is distrubuted via maven central:
|
||||
|
||||
#### Gradle
|
||||
```groovy
|
||||
implementation 'org.edgedb:edgedb:0.1.0'
|
||||
```
|
||||
|
||||
#### Maven
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.edgedb</groupId>
|
||||
<artifactId>edgedb</artifactId>
|
||||
<version>0.1.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
#### SBT
|
||||
|
||||
```scala
|
||||
libraryDependencies ++= Seq(
|
||||
"com.edgedb" % "driver" % "0.1.0"
|
||||
)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The `EdgeDBClient` class contains all the methods necessary to interact with the EdgeDB database.
|
||||
|
||||
```java
|
||||
import com.edgedb.driver.EdgeDBClient;
|
||||
|
||||
void main() {
|
||||
var client = new EdgeDBClient();
|
||||
|
||||
client.query(String.class, "SELECT 'Hello, Java!'")
|
||||
.thenAccept(System.out::println);
|
||||
}
|
||||
```
|
||||
|
||||
The `EdgeDBClient` uses `CompletionState` for asynchronous operations, allowing you
|
||||
to integrate it with your favorite asynchronous frameworks
|
||||
|
||||
```java
|
||||
import com.edgedb.driver.EdgeDBClient;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
void main() {
|
||||
var client = new EdgeDBClient();
|
||||
|
||||
Mono.fromFuture(client.querySingle(String.class, "SELECT 'Hello, Java!'"))
|
||||
.doOnNext(System.out::println)
|
||||
.block();
|
||||
}
|
||||
```
|
||||
|
||||
This also means it plays nicely with other JVM language that support asynchronous programming via `CompletionStage`
|
||||
|
||||
```kotlin
|
||||
|
||||
import com.edgedb.driver.EdgeDBClient
|
||||
import kotlinx.coroutines.future.await
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
fun main() {
|
||||
val client = EdgeDBClient()
|
||||
|
||||
runBlocking {
|
||||
client.querySingle(String::class.java, "SELECT 'Hello, Kotlin!'")
|
||||
.thenAccept { println(it) }
|
||||
.await()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```scala
|
||||
|
||||
import com.edgedb.driver.EdgeDBClient
|
||||
import scala.jdk.FutureConverters.*
|
||||
|
||||
object Main extends App {
|
||||
val client = new EdgeDBClient()
|
||||
|
||||
client.querySingle(classOf[String], "SELECT 'Hello, Scala!'")
|
||||
.asScala
|
||||
.map(println)
|
||||
}
|
||||
```
|
||||
|
||||
## Examples
|
||||
Some examples of using the Java client api can be found in the [examples](./examples) directory.
|
||||
|
||||
## Compiling
|
||||
This project uses gradle. To build the project run the following command:
|
||||
|
||||
```bash
|
||||
./gradlew build
|
||||
```
|
||||
|
|
BIN
branding/banner.png
Normal file
BIN
branding/banner.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 110 KiB |
Loading…
Reference in a new issue