gitson: A document store library for Git + JSON.

[ database, deprecated, git, json, library, public-domain ] [ Propose Tags ]
Deprecated

A simple document store library for Git + JSON, based on Aeson. Uses command line git, at least for now. No fancy indexes and stuff, but it does what I need right now. Transactions use flock, so it's safe even across completely separate programs!


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.2.0, 0.2.1, 0.3.0, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.5.2
Dependencies aeson, base (>=4.0.0.0 && <5), bytestring, directory, errors, filepath, flock, process, transformers [details]
License Apache-2.0
Copyright 2014 Val Packett <val@packett.cool>
Author Val Packett
Maintainer val@packett.cool
Revised Revision 1 made by myfreeweb at 2022-10-15T23:13:03Z
Category Database
Home page https://codeberg.org/valpackett/gitson
Source repo head: git clone https://codeberg.org/valpackett/gitson.git
Uploaded by myfreeweb at 2014-08-05T18:36:11Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 7195 total (22 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Successful builds reported [all 1 reports]

Readme for gitson-0.1.0

[back to package description]

gitson Hackage Build Status Coverage Status Apache License 2.0

A simple document store library for Git + JSON, based on Aeson. Uses command line git, at least for now. No fancy indexes and stuff, but it does what I need right now. Transactions use flock, so it's safe even across completely separate programs!

Usage

import Gitson
import Gitson.Util (insideDirectory)
import Data.Aeson.TH
import Control.Monad.IO.Class (liftIO)

data Thing = Thing { val :: Int } deriving (Eq, Show)
$(deriveJSON defaultOptions ''Thing)

main :: IO ()
main = do
  -- Creating a new "database," basically mkdir + git init
  createRepo "./content"

  -- Writing data to a "database" happens in transactions
  -- A transaction is committed after the block is executed
  -- Just like in SQL databases
  transaction "./content" $ do
    -- order: (collection) (key        ) (data)
    saveEntry "content"    "first-thing" Thing {val = 1}
    -- Collections are created automatically, like in MongoDB
    liftIO $ putStrLn "Written first-thing"
    -- You have to use liftIO to do IO actions inside of a transaction!
    -- Because a transaction is a monad transformer, WriterT actually

  -- Reading data
  -- (These are normal IO actions, so if you want
  --  to read inside of a transaction, liftIO)
  keys <- listEntries "./content/things"
       -- Just ["first-thing"]
  first-thing <- readEntry "./content/things" "first-thing" :: IO (Maybe Thing)
              -- Just Thing {val = 1}

  -- Reading data, avoiding repetition of the repo path
  insideDirectory "./content" $ do
    keys <- listEntries "things"
         -- Just ["first-thing"]
    first-thing <- readEntry "things" "first-thing" :: IO (Maybe Thing)
         -- Just Thing {val = 1}

Development

# Update to latest version of Cabal.
cabal update
cabal install cabal-install

# Initialize a sandbox and install the package's dependencies.
make install

# Configure & build the package.
make configure build

# Test package.
make test

# Benchmark package.
make bench

# Start a REPL.
make repl

# Generate documentation.
make haddock

License

Copyright 2014 Greg V floatboth@me.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.