Giter Club home page Giter Club logo

faunadb-jvm's Introduction

FaunaDB JVM Drivers

Coverage Status Maven Central License

This repository contains the FaunaDB drivers for the JVM languages. Currently, Java, Android and Scala clients are implemented.

Features

  • All drivers fully support the current version of the FaunaDB API.
  • Java and Scala clients share the same underlying library faunadb-common.
  • Java and Android clients share the same dsl library faunadb-java-dsl.
  • Supports Dropwizard Metrics hooks for stats reporting (except Android).
  • Support Android 8.0 (API level 26)

Documentation

Javadocs and Scaladocs are hosted on GitHub:

Details Documentation for each language:

Dependencies

Shared

Android

Java

  • Java 8

Scala

  • Scala 2.11.x
  • Scala 2.12.x

Using the Driver

Java

Installation

Download from the Maven central repository:

faunadb-java/pom.xml:
  <dependencies>
  ...
  <dependency>
    <groupId>com.faunadb</groupId>
    <artifactId>faunadb-java</artifactId>
    <version>2.5.6</version>
    <scope>compile</scope>
  </dependency>
  ...
</dependencies>
faunadb-android/pom.xml:
  <dependencies>
  ...
  <dependency>
    <groupId>com.faunadb</groupId>
    <artifactId>faunadb-android</artifactId>
    <version>2.5.6</version>
    <scope>compile</scope>
  </dependency>
  ...
</dependencies>
Basic Java Usage
import com.faunadb.client.FaunaClient;

import static com.faunadb.client.query.Language.*;

/**
 * This example connects to FaunaDB Cloud using the secret provided
 * and creates a new database named "my-first-database"
 */
public class Main {
    public static void main(String[] args) throws Exception {

        //Create an admin connection to FaunaDB.
        FaunaClient adminClient =
            FaunaClient.builder()
                .withSecret("put-your-key-secret-here")
                .build();

        adminClient.query(
            CreateDatabase(
                Obj("name", Value("my-first-database"))
            )
        ).get();

        client.close();
    }
}

Detailed Java Documentation can be found here

Scala

Installation

faunadb-scala/sbt
libraryDependencies += ("com.faunadb" %% "faunadb-scala" % "2.5.6")
Basic Usage
import faunadb._
import faunadb.query._
import scala.concurrent._
import scala.concurrent.duration._

/**
  * This example connects to FaunaDB Cloud using the secret provided
  * and creates a new database named "my-first-database"
  */
object Main extends App {

  import ExecutionContext.Implicits._

  val client = FaunaClient(
    secret = "put-your-secret-here"
  )

  val result = client.query(
    CreateDatabase(
      Obj("name" -> "my-first-database")
    )
  )

  Await.result(result, Duration.Inf)

  client.close()
}

Building

The faunadb-jvm project is built using sbt:

To build and run tests against cloud, set the env variable FAUNA_ROOT_KEY to your admin key secret and run sbt test from the project directory.

Alternatively, tests can be run via a Docker container with FAUNA_ROOT_KEY="your-cloud-secret" make docker-test (an alternate Debian-based JDK image can be provided via RUNTIME_IMAGE).

To run tests against an enterprise cluster or developer instance, you will also need to set FAUNA_SCHEME (http or https), FAUNA_DOMAIN and FAUNA_PORT.

License

All projects in this repository are licensed under the Mozilla Public License

faunadb-jvm's People

Contributors

alvarofauna avatar ashfire908 avatar bitbckt avatar dijkstracula avatar eaceaser avatar erickpintor avatar freels avatar jfmiii avatar marrony avatar retroryan avatar sprsquish avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.