avers-0.0.4: empty

Safe HaskellNone
LanguageHaskell2010

Avers.Types

Synopsis

Documentation

class Pk a where Source

Pk - Types which can be converted to a database primary key.

Methods

toPk :: a -> Text Source

newtype Path Source

Path

Constructors

Path 

Fields

unPath :: Text
 

newtype ObjId Source

ObjId

Constructors

ObjId 

Fields

unObjId :: Text
 

rootObjId :: ObjId Source

The root object id is used for object created internally or when there is no applicable creator.

zeroRevId :: RevId Source

The RevId which is used for the initial snapshot.

data ObjectId Source

ObjectId

Constructors

BaseObjectId !ObjId

The base object whose snapshots contain the actual content.

ReleaseObjectId !ObjId !RevId

An object describing a particualar release of the base object.

AuthorizationObjectId !ObjId

Object which contains authorization rules.

data Operation Source

The operations that can be applied to JSON values.

Constructors

Set

Set is applied to Objects. It is used for adding, updating and deleting properties from the object.

Fields

opPath :: !Path
 
opValue :: !(Maybe Value)
 
Splice

Splice is used to manipulate Arrays. It can remove and insert multiple elements in a single operation.

Fields

opPath :: !Path
 
opIndex :: !Int
 
opRemove :: !Int
 
opInsert :: ![Value]
 

data PatchError Source

Constructors

UnknownPatchError !Text 

Instances

data Release Source

Release

Constructors

Release 

(deriveJSONOptions "release") ''Release)

newtype BlobId Source

BlobId

Constructors

BlobId 

Fields

unBlobId :: Text
 

data Blob Source

Blob

Constructors

Blob 

data Session Source

The record that is stored in the database.

data ObjectType a Source

An ObjectType describes a particular type of object that is managed by Avers.

Constructors

ObjectType 

Fields

otType :: !Text

The value of the type field of the Object.

otId :: Avers ObjId

Action which generates a new id. This is so that object types can have different strategies how to generate ids.

otViews :: [SomeView a]
 

data AversConfig Source

Configuration of the Avers monad.

Constructors

AversConfig 

Fields

databaseHost :: !Text

The hostname where RethinkDB is running. The port is currently not configurable.

databaseName :: !Text

RethinkDB supports multiple databases. This is the name of the one which should be used.

influxConfig :: !(Maybe Config)

The influx server where avers reports metrics to.

putBlob :: BlobId -> Text -> ByteString -> IO ()

Function which saves the given blob in the blob store. This can be the local filesystem or an external services such as Amazon S3.

TODO: Propagate errors back to the caller.

objectTypes :: ![SomeObjectType]

All the object types which Avers knows about.

data AversState Source

Constructors

AversState 

Fields

config :: !AversConfig

A reference to the config, just in case we need it.

databaseHandlePool :: !(Pool Handle)

A pool of handles which are used to access the database.

recentRevisionCache :: !(TVar (Map ObjectId RevId))

Map from ObjectId to a recent RevId. It may be the latest or a few revisions behind.

class Monad m => MonadAvers m where Source

Methods

liftAvers :: Avers a -> m a Source

data View obj a Source

Constructors

View 

Fields

viewName :: Text

The table name is derived from the view name. Therefore it should be unique amongst all views.

viewParser :: Datum -> Either AversError a

Function which parses objects stored in this view.

viewObjectTransformer :: obj -> Avers (Maybe a)

Function which transforms an Avers Object into a type stored in the view.

viewIndices :: [Index]

Secondary indices defined on the view.

data SomeView obj where Source

Constructors

SomeView :: (ToDatum a, FromDatum a, FromJSON obj, ToJSON a) => View obj a -> SomeView obj