rethinkdb-client-driver-0.0.0.1: Client driver for RethinkDB

Safe HaskellNone

Database.RethinkDB

Synopsis

Documentation

newHandle :: IO HandleSource

Create a new handle to the RethinkDB server.

run :: (Any a, FromResponse (Result a)) => Handle -> Exp a -> IO (Res a)Source

Start a new query and wait for its (first) result. If the result is an single value (Datum), then three will be no further results. If it is a sequence, then you must consume results until the sequence ends.

nextChunk :: FromResponse (Sequence a) => Handle -> Sequence a -> IO (Either Error (Sequence a))Source

Get the next chunk of a sequence. It is an error to request the next chunk if the sequence is already Done,

collect :: FromResponse (Sequence a) => Handle -> Sequence a -> IO (Either Error (Vector a))Source

Collect all the values in a sequence and make them available as a 'Vector a'.

data Error Source

Constructors

ProtocolError !Text

An error on the protocol level. Perhaps the socket was closed unexpectedly, or the server sent a message which the driver could not parse.

ClientError 
CompileError 
RuntimeError 

Instances

data Exp a Source

Instances

IsString (Exp Text)

Convenience to for automatically converting a Text to a constant expression.

ToJSON a => ToJSON (Exp a) 

type Array = Vector DatumSource

Arrays are vectors of Datum.

type Object = HashMap Text DatumSource

Objects are maps from Text to Datum. Like Aeson, we're using HashMap.

data Datum Source

A sumtype covering all the primitive types which can appear in queries or responses.

data Sequence a Source

Sequences are a bounded list of items. The server may split the sequence into multiple chunks when sending it to the client. When the response is a partial sequence, the client may request additional chunks until it gets a Done.

Instances

constant :: IsDatum a => a -> Exp aSource

Convert a Datum to an Exp.

data Table Source

Tables are something you can select objects from.

This type is not exported, and merely serves as a sort of phantom type. On the client tables are converted to a Sequence.

data Database Source

A Database is something which contains tables. It is a server-only type.

data SingleSelection Source

SingleSelection is essentially a 'Maybe Object', where Nothing is represented with Null in the network protocol.

type Res a = Either Error (Result a)Source

The result of a query. It is either an error or a result (which depends on the type of the query expression). This type is named to be symmetrical to Exp, so we get this nice type for run.

 run :: Handle -> Exp a -> IO (Res a)

class ToJSON a => Any a Source

Any value which can appear in RQL terms.

For convenience we require that it can be converted to JSON, but that is not required for all types. Only types which satisfy IsDatum are eventually converted to JSON.

Instances

Any Bool

For a boolean type, we're reusing the standard Haskell Bool type.

Any Double

Numbers are Double (unlike Aeson, which uses Scientific). No particular reason.

Any Text

For strings, we're using the Haskell Text type.

Any Database 
Any SingleSelection 
Any Table 
Any Object 
Any Array 
Any Datum 
Any a => Any (Sequence a) 

class Any a => IsSequence a Source

Instances