Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Gitson is a simple document store library for Git + JSON.
- type TransactionWriter = WriterT [IO ()]
- createRepo :: FilePath -> IO ()
- transaction :: (MonadIO i, MonadBaseControl IO i) => FilePath -> TransactionWriter i () -> i ()
- saveDocument :: (MonadIO i, ToJSON a) => FilePath -> FileName -> a -> TransactionWriter i ()
- saveNextDocument :: (MonadIO i, ToJSON a) => FilePath -> FileName -> a -> TransactionWriter i ()
- saveDocumentById :: (MonadIO i, ToJSON a) => FilePath -> Int -> a -> TransactionWriter i ()
- saveDocumentByName :: (MonadIO i, ToJSON a) => FilePath -> String -> a -> TransactionWriter i ()
- listCollections :: MonadIO i => i [FilePath]
- listDocumentKeys :: MonadIO i => FilePath -> i [FileName]
- listEntries :: (MonadIO i, FromJSON a) => FilePath -> i [a]
- readDocument :: (MonadIO i, FromJSON a) => FilePath -> FileName -> i (Maybe a)
- readDocumentById :: (MonadIO i, FromJSON a) => FilePath -> Int -> i (Maybe a)
- readDocumentByName :: (MonadIO i, FromJSON a) => FilePath -> String -> i (Maybe a)
- documentIdFromName :: MonadIO i => FilePath -> String -> i (Maybe Int)
- documentNameFromId :: MonadIO i => FilePath -> Int -> i (Maybe String)
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").