Safe Haskell | None |
---|
Gitson is a simple document store library for Git + JSON.
- type TransactionWriter = WriterT [IO ()] IO ()
- createRepo :: FilePath -> IO ()
- transaction :: FilePath -> TransactionWriter -> IO ()
- saveDocument :: ToJSON a => FilePath -> FileName -> a -> TransactionWriter
- saveNextDocument :: ToJSON a => FilePath -> FileName -> a -> TransactionWriter
- listCollections :: IO [FilePath]
- listDocumentKeys :: FilePath -> IO [FileName]
- listEntries :: FromJSON a => FilePath -> IO [a]
- readDocument :: FromJSON a => FilePath -> FileName -> IO (Maybe a)
- readDocumentById :: FromJSON a => FilePath -> Int -> IO (Maybe a)
- readDocumentByName :: FromJSON a => FilePath -> String -> IO (Maybe a)
- documentIdFromName :: FilePath -> String -> IO (Maybe Int)
- documentNameFromId :: FilePath -> Int -> IO (Maybe String)
Documentation
type TransactionWriter = WriterT [IO ()] IO ()Source
A transaction monad.
createRepo :: FilePath -> IO ()Source
Creates a git repository under a given path.
transaction :: FilePath -> TransactionWriter -> IO ()Source
Executes a blocking transaction on a repository, committing the results to git.
saveDocument :: ToJSON a => FilePath -> FileName -> a -> TransactionWriterSource
Adds a write action to a transaction.
saveNextDocument :: ToJSON a => FilePath -> FileName -> a -> TransactionWriterSource
Adds a write action to a transaction. The key will start with a numeric id, incremented from the last id in the collection.
listCollections :: IO [FilePath]Source
Lists collections in the current repository.
listDocumentKeys :: FilePath -> IO [FileName]Source
Lists document keys in a collection.
listEntries :: FromJSON a => FilePath -> IO [a]Source
Lists entries in a collection.
readDocument :: FromJSON a => FilePath -> FileName -> IO (Maybe a)Source
Reads a document from a collection by key.
readDocumentById :: FromJSON a => FilePath -> Int -> IO (Maybe a)Source
Reads a document from a collection by numeric id (for example, key 00001-hello has id 1).
readDocumentByName :: FromJSON a => FilePath -> String -> IO (Maybe a)Source
Reads a document from a collection by name (for example, key 00001-hello has name hello).
documentIdFromName :: FilePath -> String -> IO (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 :: FilePath -> Int -> IO (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!