public class FaunaClient extends Object implements AutoCloseable
This client is asynchronous, so all methods that perform latent operations return a ListenableFuture.
Queries are constructed by using the static helpers in the Language package.
Example:
import static com.faunadb.client.query.Language.*;
FaunaClient client = FaunaClient.builder().withSecret("someAuthToken").build();
client.query(Get(Ref("some/ref")));
Language| Modifier and Type | Class and Description |
|---|---|
static class |
FaunaClient.Builder
A builder for creating an instance of
FaunaClient |
| Modifier and Type | Method and Description |
|---|---|
static FaunaClient.Builder |
builder()
Creates a new
FaunaClient.Builder |
void |
close()
Frees any resources held by the client.
|
FaunaClient |
newSessionClient(String secret)
Creates a session client with the user secret provided.
|
ListenableFuture<Value> |
query(Expr expr)
Issues a Query to FaunaDB.
|
ListenableFuture<ImmutableList<Value>> |
query(List<? extends Expr> exprs)
Issues multiple queries to FaunaDB.
|
public static FaunaClient.Builder builder()
FaunaClient.Builderpublic FaunaClient newSessionClient(String secret)
Connection instance.secret - user secret for the session clientFaunaClientpublic void close()
Connection.close in interface AutoCloseablepublic ListenableFuture<Value> query(Expr expr)
Queries are modeled through the FaunaDB query language, represented by the helper functions in the
Language class.
Responses are modeled as a general response tree. Each node is a Value, and
can be coerced to structured types through various methods on that class.
expr - The query expression to be sent to FaunaDB.ListenableFuture containing the root node of the Response tree.Value,
Languagepublic ListenableFuture<ImmutableList<Value>> query(List<? extends Expr> exprs)
These queries are sent to FaunaDB in a single request, and are evaluated. The list of response nodes is returned in the same order as the issued queries.
See query(Expr) for more information on the individual queries.
exprs - the list of query expressions to be sent to FaunaDB.ListenableFuture containing an ordered list of root response nodes.