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

Safe HaskellSafe
LanguageHaskell2010

Gitson

Description

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

Synopsis

Documentation

type TransactionWriter = WriterT [IO ()] Source

A transaction monad.

createRepo :: FilePath -> IO () Source

Creates a git repository under a given path.

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

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

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

Adds a write action to a transaction.

saveNextDocument :: (MonadIO 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, 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, 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 => i [FilePath] Source

Lists collections in the current repository.

listDocumentKeys :: MonadIO i => FilePath -> i [FileName] Source

Lists document keys in a collection.

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

Lists entries in a collection.

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

Reads a document from a collection by key.

readDocumentById :: (MonadIO 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, 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 => 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 => 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!