gdritter repos tansu-berkeleydb / 52180fd
Added simple readme Getty Ritter 5 years ago
1 changed file(s) with 44 addition(s) and 0 deletion(s). Collapse all Expand all
1 # Tansu-BerkeleyDB
2
3 **WARNING: DO NOT USE THIS LIBRARY.** Like, seriously, there
4 are a ton of other storage libraries that aren't fly-by-night
5 like this one.
6
7 This is a backend for the
8 [`tansu`](http://github.com/aisamanra/tansu)
9 library that supports storing and retrieving data using the
10 [Berkeley DB](https://en.wikipedia.org/wiki/Berkeley_DB)
11 library. Be aware that Berkeley DB, and therefore this code
12 as well, is GPL-licensed, and thus cannot be used in commercial
13 products.
14
15 ## Example
16
17 ~~~.haskell
18 {-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
19
20 module Main where
21
22 import Data.Serialize (Serialize)
23 import GHC.Generics (Generic)
24
25 import Database.Tansu ((=:), get, run)
26 import Database.Tansu.Backend.BerkeleyDb (withBerkeleyDb)
27
28 data Person = Person { name :: String, age :: Int }
29 deriving (Eq, Show, Generic, Serialize)
30
31 main :: IO ()
32 main = withBerkeleyDb "sample.db" $ \ db -> do
33 run db $ do
34 "alex" =: Person "alex" 33
35 "blake" =: Person "blake" 22
36
37 Right age <- run db (age `fmap` get "blake")
38 putStrLn $ "Blake's age is " ++ show age
39 ~~~
40
41 ## Usage
42
43 Please see the corresponding section of the
44 [`tansu` library page](http://github.com/aisamanra/tansu#usage).