Client
public final class Client
Client represents a HTTP client for a FaunaDB server. It provides
methods, such as query and query(batch:) that you can use to execute
queries in your server.
Note
This class is meant to be reused as much as possible. If you need to connect to the same server but using a different key’s secret, usenewSessionClient method instead of creating a new Client instance.
-
Declaration
Swift
public init(secret: String, endpoint: URL = defaultEndpoint, session: URLSession? = nil)Parameters
secretThe key’s secret to be used to authenticate requests.
endpointThe URL address of your FaunaDB server. Default: https://db.fauna.com.
sessionThe
URLSessionobject to be used while performing HTTP requests to FaunaDB. Default:URLSession(configuration: URLSessionConfiguration.default). -
Returns a new
Clientinstance for the same FaunaDB server but using a different key’s secret to authenticate HTTP requests. The new client shares its parent’s resources, such as its URLSession.Declaration
Swift
public func newSessionClient(secret: String) -> ClientParameters
secretThe key’s secret to be used to authenticate HTTP requests.
-
Sends a query to the FaunaDB server. All queries are executed asynchronously.
QueryResultwill be fulfilled once the query finishes to run, or fail.Declaration
Swift
public func query(_ expr: Expr) -> QueryResult<Value>Parameters
exprThe query expression to be sent. Check
FaunaDB.Exprfor more information. -
Sends a batch of queries to the FaunaDB server. All queries are executed asynchronously.
QueryResultwill be fulfilled once all queries finishes to run, or fail. The result array will be in the same order as the request array.Declaration
Swift
public func query(batch: [Expr]) -> QueryResult<[Value]>Parameters
batchA sequence of query expressions to be sent to FaunaDB.
Client Class Reference