gitson-0.5.2: A document store library for Git + JSON.

Safe HaskellNone
LanguageHaskell2010

Gitson

Description

Gitson is a simple document store library for Git + JSON.

Synopsis

Documentation

type TransactionWriter = WriterT [IO ()] Source #

A transaction monad.

class HasGitsonLock m where Source #

Minimal complete definition

getGitsonLock

Methods

getGitsonLock :: m (MVar ()) Source #

Instances

createRepo :: FilePath -> IO () Source #

Creates a git repository under a given path.

transaction :: (MonadIO i, Functor i, MonadBaseControl IO i, HasGitsonLock i) => FilePath -> TransactionWriter i () -> i () Source #

Executes a blocking transaction on a repository, committing the results to git.

saveDocument :: (MonadIO i, Functor i, ToJSON a) => FilePath -> FileName -> a -> TransactionWriter i () Source #

Adds a write action to a transaction.

saveNextDocument :: (MonadIO i, Functor i, ToJSON a) => FilePath -> FileName -> a -> TransactionWriter i () Source #

Adds a write action to a transaction. The key will start with a numeric id, incremented from the last id in the collection.

saveDocumentById :: (MonadIO i, Functor i, ToJSON a) => FilePath -> Int -> a -> TransactionWriter i () Source #

Adds a write action to a transaction. Will update the document with the given numeric id.

saveDocumentByName :: (MonadIO i, Functor i, ToJSON a) => FilePath -> String -> a -> TransactionWriter i () Source #

Adds a write action to a transaction. Will update the document with the given numeric id.

listCollections :: (MonadIO i, Functor i) => i [FilePath] Source #

Lists collections in the current repository.

listDocumentKeys :: (MonadIO i, Functor i) => FilePath -> i [FileName] Source #

Lists document keys in a collection.

listEntries :: (MonadIO i, Functor i, FromJSON a) => FilePath -> i [a] Source #

Lists entries in a collection.

readDocument :: (MonadIO i, Functor i, FromJSON a) => FilePath -> FileName -> i (Maybe a) Source #

Reads a document from a collection by key.

readDocumentById :: (MonadIO i, Functor i, FromJSON a) => FilePath -> Int -> i (Maybe a) Source #

Reads a document from a collection by numeric id (for example, key "00001-hello" has id 1).

readDocumentByName :: (MonadIO i, Functor i, FromJSON a) => FilePath -> String -> i (Maybe a) Source #

Reads a document from a collection by name (for example, key "00001-hello" has name "hello").

documentIdFromName :: (MonadIO i, Functor i) => FilePath -> String -> i (Maybe Int) Source #

Returns a document's id by name (for example, "hello" will return 23 when key "00023-hello" exists). Does not read the document!

documentNameFromId :: (MonadIO i, Functor i) => FilePath -> Int -> i (Maybe String) Source #

Returns a document's name by id (for example, 23 will return "hello" when key "00023-hello" exists). Does not read the document!

documentFullKey :: (MonadIO i, Functor i) => FilePath -> Finder -> i (Maybe FileName) Source #

findById :: Int -> Finder Source #

findByName :: String -> Finder Source #