Safe Haskell | None |
---|---|
Language | Haskell2010 |
Gitson is a simple document store library for Git + JSON.
- type TransactionWriter = WriterT [IO ()]
- class HasGitsonLock m where
- getGitsonLock :: HasGitsonLock m => m (MVar ())
- createRepo :: FilePath -> IO ()
- transaction :: (MonadIO i, Functor i, MonadBaseControl IO i, HasGitsonLock i) => FilePath -> TransactionWriter i () -> i ()
- saveDocument :: (MonadIO i, Functor i, ToJSON a) => FilePath -> FileName -> a -> TransactionWriter i ()
- saveNextDocument :: (MonadIO i, Functor i, ToJSON a) => FilePath -> FileName -> a -> TransactionWriter i ()
- saveDocumentById :: (MonadIO i, Functor i, ToJSON a) => FilePath -> Int -> a -> TransactionWriter i ()
- saveDocumentByName :: (MonadIO i, Functor i, ToJSON a) => FilePath -> String -> a -> TransactionWriter i ()
- listCollections :: (MonadIO i, Functor i) => i [FilePath]
- listDocumentKeys :: (MonadIO i, Functor i) => FilePath -> i [FileName]
- listEntries :: (MonadIO i, Functor i, FromJSON a) => FilePath -> i [a]
- readDocument :: (MonadIO i, Functor i, FromJSON a) => FilePath -> FileName -> i (Maybe a)
- readDocumentById :: (MonadIO i, Functor i, FromJSON a) => FilePath -> Int -> i (Maybe a)
- readDocumentByName :: (MonadIO i, Functor i, FromJSON a) => FilePath -> String -> i (Maybe a)
- documentIdFromName :: (MonadIO i, Functor i) => FilePath -> String -> i (Maybe Int)
- documentNameFromId :: (MonadIO i, Functor i) => FilePath -> Int -> i (Maybe String)
- documentFullKey :: (MonadIO i, Functor i) => FilePath -> Finder -> i (Maybe FileName)
- findById :: Int -> Finder
- findByName :: String -> Finder
Documentation
type TransactionWriter = WriterT [IO ()] Source #
A transaction monad.
class HasGitsonLock m where Source #
getGitsonLock :: m (MVar ()) Source #
getGitsonLock :: HasGitsonLock m => m (MVar ()) Source #
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!
findByName :: String -> Finder Source #