1# The Project:M36 Simple Client Interface
5For common use cases, the `ProjectM36.Client.Simple` API can assist in transaction management. The API is designed to be less overwhelming than the full-featured `ProjectM36.Client` (see [documentation](projectm36_client_library.markdown)).
7As such, not all features are available through the simple API, but, because the simple API is a thin layer over the complete API, the user may dip into the complete API at any time.
11 1. Create a `DbConn` to connect to the database:
14 import ProjectM36.Client.Simple
16 let connInfo = InProcessConnectionInfo (CrashSafePersistence "my.db") emptyNotificationCallback []
17 eDbconn <- simpleConnectProjectM36 connInfo
20 The result is `Either` a `DbError` or a connection linked to the `"master"` branch of the database.
22 1. Run the `Db` monad using `withTransaction`:
25 withTransaction dbconn $ do
26 execute $ Assign "x" (ExistingRelation relationTrue)
27 query $ RelationVariable "x" ()
30 If there is an error in the above update or query, then an exception is thrown behind the scenes which cancels the transactions, rolls back any changes, and the error is returned by `withTransaction`.
32 `query` is used with `RelationalExpr` queries which read the current database state.
34 `execute` is used with `DatabaseContextExpr` values which write the current database state.
36 To execute a query without cancelling the transaction on an error, use the `queryOrErr` and `executeOrErr` variants.
38 1. Close the connection:
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list