mirror of
https://github.com/maxkratz/edgedb-java.git
synced 2024-10-13 19:03:46 +00:00
The official Java client library for EdgeDB
.github/workflows | ||
branding | ||
dbschema | ||
docs | ||
examples | ||
gradle/wrapper | ||
src/driver | ||
tools/testgen | ||
.gitignore | ||
build.gradle | ||
edgedb.toml | ||
gradlew | ||
gradlew.bat | ||
LICENSE | ||
README.md | ||
settings.gradle |
Installation
The Java binding is distrubuted via maven central:
Gradle
implementation 'com.edgedb:driver:0.2.3'
Maven
<dependency>
<groupId>com.edgedb</groupId>
<artifactId>driver</artifactId>
<version>0.2.3</version>
</dependency>
SBT
libraryDependencies ++= Seq(
"com.edgedb" % "driver" % "0.2.3"
)
Usage
The EdgeDBClient
class contains all the methods necessary to interact with the EdgeDB database.
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 CompletionStage
for asynchronous operations, allowing you
to integrate it with your favorite asynchronous frameworks
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
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()
}
}
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 directory.
Compiling
This project uses gradle. To build the project run the following command:
./gradlew build