Popularity
2.2
Growing
Activity
0.0
Stable
2
3
0

Monthly Downloads: 13
Programming language: Haskell
License: MIT License
Tags: Database    
Latest version: v0.3.0.0

ejdb2-binding alternatives and similar packages

Based on the "Database" category.
Alternatively, view ejdb2-binding alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of ejdb2-binding or a related project?

Add another 'Database' Package

README

ejdb2haskell

ejdb2haskell is a Haskell binding to ejdb2, an embeddable JSON Database engine C library.

Requirements

libejdb2

Install libejdb2 by installing ejdb2

In Arch Linux I do:

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
sudo make install

Build

cabal build

Usage

Every API are tested, so have a look to test folder.

putNewTest :: IO Database -> TestTree
putNewTest databaseIO = testCase "putNewTest" $ do
    database <- databaseIO
    id <- putNew database "plants" plant
    storedPlant <- getById database "plants" id
    storedPlant @?= Just plant
  where
    plant = Plant { name        = Just "pinus"
                  , isTree      = Just True
                  , year        = Just 1753
                  , description = Just "wow 🌲"
                  }

getListTest' :: IO Database -> TestTree
getListTest' databaseIO = testCase "getList'" $ do
    database <- databaseIO
    query <- Query.fromString "@plants/[isTree=:tree] | asc /name"
    Query.setBool False "tree" query
    plants <- getList' database query
    plants @?= [ Just Plant { id          = Just 2
                            , name        = Just "gentiana brentae"
                            , isTree      = Just False
                            , year        = Just 2008
                            , description = Just "violet 🌺flower"
                            , ratio       = Nothing
                            }
               , Just Plant { id          = Just 3
                            , name        = Just "leontopodium"
                            , isTree      = Just False
                            , year        = Just 1817
                            , description = Just "tipical alpine flower"
                            , ratio       = Nothing
                            }
               , Just Plant { id          = Just 4
                            , name        = Just "leucanthemum vulgare"
                            , isTree      = Just False
                            , year        = Just 1778
                            , description =
                                  Just "very common flower in Italy 🍕"
                            , ratio       = Just 1.618
                            }
               ]