on master help sign in
update examples due to refactoring
929580fAgentM
examples/PersistClient.hs+6−5
@@ -3,7 +3,7 @@
3{- A simple example of using the persistent-ProjectM36 driver. -}
3{- A simple example of using the persistent-ProjectM36 driver. -}
4import Database.Persist.ProjectM36 hiding (executeDatabaseContextExpr)
4import Database.Persist.ProjectM36 hiding (executeDatabaseContextExpr)
5import ProjectM36.Client
5import ProjectM36.Client
6−import ProjectM36.Atom
6+import ProjectM36.DataTypes.Primitive
7import System.Exit
7import System.Exit
8import System.IO
8import System.IO
9import Database.Persist
9import Database.Persist
@@ -27,10 +27,11 @@ errDie out = hPutStrLn stderr out >> exitFailure
27
27
28defPersonRel :: SessionId -> Connection -> IO ()
28defPersonRel :: SessionId -> Connection -> IO ()
29defPersonRel sessionId conn = do
29defPersonRel sessionId conn = do
30− maybeErr <- executeDatabaseContextExpr sessionId conn (Define "person" (attributesFromList [Attribute "name" stringAtomType, Attribute "age" intAtomType, Attribute "id" stringAtomType]))
30+ let attrList = [Attribute "name" textAtomType, Attribute "age" intAtomType, Attribute "id" textAtomType]
31+ maybeErr <- executeDatabaseContextExpr sessionId conn (Define "person" (map NakedAttributeExpr attrList))
31− case maybeErr of
32+ case maybeErr of
32− Nothing -> return ()
33+ Nothing -> return ()
33− Just err -> errDie (show err)
34+ Just err -> errDie (show err)
34
35
35main :: IO ()
36main :: IO ()
36main = do
37main = do
examples/SimpleClient.hs+4−5
@@ -21,11 +21,10 @@ main = do
21 Left err -> putStrLn (show err)
21 Left err -> putStrLn (show err)
22 Right sessionId -> do
22 Right sessionId -> do
23 --4. define a new relation variable with a DatabaseContext expression
23 --4. define a new relation variable with a DatabaseContext expression
24− let attrExprs = [AttributeAndTypeNameExpr "name" (PrimitiveTypeConstructor "Text" textAtomType),
24+ let attrList = [Attribute "name" textAtomType,
25− AttributeAndTypeNameExpr "age" (PrimitiveTypeConstructor "Int" intAtomType)]
25+ Attribute "age" intAtomType]
26− attrs = attributesFromList [Attribute "name" textAtomType,
26+ attrs = attributesFromList attrList
27− Attribute "age" intAtomType]
28− mErr1 <- executeDatabaseContextExpr sessionId conn (Define "person" attrExprs)
27+ mErr1 <- executeDatabaseContextExpr sessionId conn (Define "person" (map NakedAttributeExpr attrList))
29 putStrLn (show mErr1)
28 putStrLn (show mErr1)
30 --5. add a tuple to the relation referenced by the relation variable
29 --5. add a tuple to the relation referenced by the relation variable
31 let (Right tupSet) = mkTupleSetFromList attrs [[textAtom "Bob", intAtom 45]]
30 let (Right tupSet) = mkTupleSetFromList attrs [[textAtom "Bob", intAtom 45]]