class FaunaClient extends AnyRef
The Scala native client for FaunaDB.
Create a new client using faunadb.FaunaClient.apply.
Query requests are made asynchronously: All methods will return a scala.concurrent.Future.
Example:
case class User(ref: RefV, name: String, age: Int) val client = FaunaClient(secret = "myKeySecret") val fut = client.query(Get(Ref(Class("users"), "123"))) val instance = Await.result(fut, 5.seconds) val userCast = for { ref <- instance("ref").to[RefV] name <- instance("data", "name").to[String] age <- instance("data", "age").to[Int] } yield { User(ref, name, age) } userCast.get
- Alphabetic
- By Inheritance
- FaunaClient
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
lastTxnTime: Long
Get the freshest timestamp reported to this client.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
query(exprs: Iterable[Expr], timeout: Option[FiniteDuration])(implicit ec: ExecutionContext): Future[IndexedSeq[Value]]
Issues multiple queries as a single transaction.
Issues multiple queries as a single transaction.
- exprs
the queries to run.
- timeout
the timeout for the current query. It replaces the timeout value set for this faunadb.FaunaClient if any, for the scope of this query. The timeout value has milliseconds precision.
- ec
the
ExecutionContext
used to run the query asynchronously.- returns
A scala.concurrent.Future containing an IndexedSeq of the results of each query. Each result is an instance of faunadb.values.Value, which can be cast to a typed value using the faunadb.values.Field API. If *any* query fails, a failed future is returned.
-
def
query(exprs: Iterable[Expr], timeout: FiniteDuration)(implicit ec: ExecutionContext): Future[IndexedSeq[Value]]
Issues multiple queries as a single transaction.
Issues multiple queries as a single transaction.
- exprs
the queries to run.
- timeout
the timeout for the current query. It replaces the timeout value set for this faunadb.FaunaClient if any, for the scope of this query. The timeout value has milliseconds precision.
- ec
the
ExecutionContext
used to run the query asynchronously.- returns
A scala.concurrent.Future containing an IndexedSeq of the results of each query. Each result is an instance of faunadb.values.Value, which can be cast to a typed value using the faunadb.values.Field API. If *any* query fails, a failed future is returned.
-
def
query(exprs: Iterable[Expr])(implicit ec: ExecutionContext): Future[IndexedSeq[Value]]
Issues multiple queries as a single transaction.
Issues multiple queries as a single transaction.
- exprs
the queries to run.
- ec
the
ExecutionContext
used to run the query asynchronously.- returns
A scala.concurrent.Future containing an IndexedSeq of the results of each query. Each result is an instance of faunadb.values.Value, which can be cast to a typed value using the faunadb.values.Field API. If *any* query fails, a failed future is returned.
-
def
query(expr: Expr, requestParameters: RequestParameters)(implicit ec: ExecutionContext): Future[Value]
Issues a query.
Issues a query.
- expr
the query to run, created using the query dsl helpers in faunadb.query.
- requestParameters
Additional metadata to be passed along with the request.
- ec
the
ExecutionContext
used to run the query asynchronously.- returns
A scala.concurrent.Future containing the query result. The result is an instance of faunadb.values.Result, which can be cast to a typed value using the faunadb.values.Field API. If the query fails, failed future is returned.
-
def
query(expr: Expr, timeout: Option[FiniteDuration])(implicit ec: ExecutionContext): Future[Value]
Issues a query.
Issues a query.
- expr
the query to run, created using the query dsl helpers in faunadb.query.
- timeout
the timeout for the current query. It replaces the timeout value set for this faunadb.FaunaClient if any for the scope of this query. The timeout value has milliseconds precision.
- ec
the
ExecutionContext
used to run the query asynchronously.- returns
A scala.concurrent.Future containing the query result. The result is an instance of faunadb.values.Result, which can be cast to a typed value using the faunadb.values.Field API. If the query fails, failed future is returned.
-
def
query(expr: Expr, timeout: FiniteDuration)(implicit ec: ExecutionContext): Future[Value]
Issues a query.
Issues a query.
- expr
the query to run, created using the query dsl helpers in faunadb.query.
- timeout
the timeout for the current query. It replaces the timeout value set for this faunadb.FaunaClient if any for the scope of this query. The timeout value has milliseconds precision.
- ec
the
ExecutionContext
used to run the query asynchronously.- returns
A scala.concurrent.Future containing the query result. The result is an instance of faunadb.values.Result, which can be cast to a typed value using the faunadb.values.Field API. If the query fails, failed future is returned.
-
def
query(expr: Expr)(implicit ec: ExecutionContext): Future[Value]
Issues a query.
Issues a query.
- expr
the query to run, created using the query dsl helpers in faunadb.query.
- ec
the
ExecutionContext
used to run the query asynchronously.- returns
A scala.concurrent.Future containing the query result. The result is an instance of faunadb.values.Result, which can be cast to a typed value using the faunadb.values.Field API. If the query fails, failed future is returned.
-
def
queryWithMetrics(expr: Expr, requestParameters: RequestParameters)(implicit ec: ExecutionContext): Future[MetricsResponse]
Issues a query.
Issues a query.
- expr
the query to run, created using the query dsl helpers in faunadb.query.
- ec
the
ExecutionContext
used to run the query asynchronously.- returns
A scala.concurrent.Future containing the query result. The result is an instance of faunadb.values.Result, which can be cast to a typed value using the faunadb.values.Field API. If the query fails, failed future is returned.
-
def
queryWithMetrics(expr: Expr, timeout: Option[FiniteDuration])(implicit ec: ExecutionContext): Future[MetricsResponse]
Issues a query.
Issues a query.
- expr
the query to run, created using the query dsl helpers in faunadb.query.
- timeout
the timeout for the current query. It replaces the timeout value set for this faunadb.FaunaClient if any for the scope of this query. The timeout value has milliseconds precision.
- ec
the
ExecutionContext
used to run the query asynchronously.- returns
A scala.concurrent.Future containing the query result. The result is an instance of faunadb.values.Result, which can be cast to a typed value using the faunadb.values.Field API. If the query fails, failed future is returned.
-
def
sessionClient(secret: String): FaunaClient
Create a new session client.
Create a new session client. The returned session client shares its parent com.faunadb.common.Connection instance.
- secret
user secret for the session client
- returns
a new session client
-
def
sessionWith[A](secret: String)(session: (FaunaClient) ⇒ A): A
Creates a new scope to execute session queries.
Creates a new scope to execute session queries. Queries submitted within the session scope will be authenticated with the secret provided. A session client shares its parent's com.faunadb.common.Connection instance.
- secret
user secret for the session scope
- session
a function that receives a session client
- returns
the value produced by the session function
-
def
stream(expr: Expr, fields: Seq[EventField] = Nil, snapshot: Boolean = false)(implicit ec: ExecutionContext): Future[Publisher[Value]]
Creates a subscription to the result of the given read-only expression.
Creates a subscription to the result of the given read-only expression. When executed, the expression must only perform reads and produce a single streamable type, such as a reference or a version. Expressions that attempt to perform writes or produce non-streamable types will result in an error. Otherwise, any expression can be used to initiate a stream, including user-defined function calls.
- expr
the query to subscribe to.
- fields
fields to opt-in on the events.
- snapshot
if true the second event will be a snapshot event of the target
- ec
the
ExecutionContext
used to run the query asynchronously.- returns
A scala.concurrent.Future containing a java.util.concurrent.Flow.Publisher which yields element of type faunadb.values.Value. The scala.concurrent.Future fails if the stream cannot be setup.
-
def
syncLastTxnTime(timestamp: Long): Unit
Sync the freshest timestamp seen by this client.
Sync the freshest timestamp seen by this client.
This has no effect if staler than currently stored timestamp. WARNING: This should be used only when coordinating timestamps across multiple clients. Moving the timestamp arbitrarily forward into the future will cause transactions to stall.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )