Giter VIP home page Giter VIP logo

ejdb2haskell's Introduction

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 <- fromString "@plants/[isTree=:tree] | asc /name" $ setBool False "tree"
    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
                            }
               ]

ejdb2haskell's People

Contributors

cescobaz avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.