hasbolt-extras-0.0.0.4: Extras for hasbolt library

Safe HaskellNone
LanguageHaskell2010

Database.Bolt.Extras.Template

Synopsis

Documentation

class FromValue a where Source #

FromValue means that something can be converted from Bolt Value.

Minimal complete definition

fromValue

Methods

fromValue :: Value -> a Source #

type Label = Text Source #

Alias for Neo4j label.

class Labels a where Source #

Minimal complete definition

getLabels

Methods

getLabels :: a -> [Label] Source #

data Node :: * #

Constructors

Node 

Fields

Instances

class NodeLike a where Source #

NodeLike class represents convertable into and from Node.

Minimal complete definition

toNode, fromNode

Methods

toNode :: a -> Node Source #

fromNode :: Node -> a Source #

class Properties a where Source #

Minimal complete definition

getProps

Methods

getProps :: a -> Map Text Value Source #

type Property = (Text, Value) Source #

Alias for Neo4j property.

data Relationship :: * #

Constructors

Relationship 

Fields

class ToValue a where Source #

ToValue means that something can be converted into Bolt Value.

Minimal complete definition

toValue

Methods

toValue :: a -> Value Source #

class URelationLike a where Source #

URelationLike class represents convertable into and from URelationship.

Minimal complete definition

toURelation, fromURelation

data Value :: * #

The Value datatype generalizes all primitive BoltValues

Constructors

N () 
B Bool 
I Int 
F Double 
T Text 
L [Value] 
M (Map Text Value) 
S Structure 

Instances

Eq Value 

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Show Value 

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

ToCypher Value Source #

Convertation for Value into Cypher.

Methods

toCypher :: Value -> Text Source #

ToCypher Property Source #

Converts property with name and value to name:value.

ToCypher [Property] Source #

Several properties are formatted with concatenation.

Methods

toCypher :: [Property] -> Text Source #

RecordValue (Map Text Value) 

Methods

exact :: Monad m => Value -> m (Map Text Value) #

makeNodeLike :: Name -> Q [Dec] Source #

Make an instance of NodeLike class. Only data types with one constructor are currently supported. Each field is transformed into Text key and its value is transformed into a Value. For example, we have a structure

data Foo = Bar { baz  :: Double
               , quux :: Text
               , quuz :: Int
               }

You can make it instance of NodeClass by writing > makeNodeLike ''Foo

Then you may create example and convert it into from from Node:

ghci>:set -XOverloadedStrings
ghci> let foo = Bar 42.0 "Loren ipsum" 7
ghci> toNode foo
Node {nodeIdentity = -1, labels = ["Foo"], nodeProps = fromList [("baz",F 42.0),("quux",T "Loren ipsum"),("quuz",I 7)]}
ghci> fromNode . toNode $ foo :: Foo
Bar {baz = 42.0, quux = "Loren ipsum", quuz = 7}

makeURelationLike :: Name -> Q [Dec] Source #

Make an instance of URelationLike class. Transformations are the same as in NodeLike instance declaration with the only one difference: URelationship holds only one label (or type), but Node holds list of labels.