| License | AGPL-3 |
|---|---|
| Maintainer | stu235271@mail.uni-kiel.de stu236925@mail.uni-kiel.de |
| Safe Haskell | None |
| Language | Haskell2010 |
Docs.Database
Description
This module provides an implementation-agnostic database abstraction. An implementation for a PostreSQL Database is Docs.Hasql.Database.
Documentation
class Monad m => HasNow (m :: Type -> Type) where Source #
Instances
| HasNow HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods | |
class Monad m => HasRollback (m :: Type -> Type) where Source #
Instances
| HasRollback HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods rollback :: HasqlTransaction () Source # | |
class HasIsSuperAdmin m => HasCheckPermission (m :: Type -> Type) where Source #
Methods
checkDocumentPermission :: UserID -> DocumentID -> Permission -> m Bool Source #
Check if a user has a specific permission on a document.
Instances
| HasCheckPermission HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods checkDocumentPermission :: UserID -> DocumentID -> Permission -> HasqlSession Bool Source # | |
| HasCheckPermission HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods checkDocumentPermission :: UserID -> DocumentID -> Permission -> HasqlTransaction Bool Source # | |
class HasIsSuperAdmin m => HasIsGroupAdmin (m :: Type -> Type) where Source #
Methods
isGroupAdmin :: UserID -> GroupID -> m Bool Source #
Check whether a user is andmin in a group.
Instances
| HasIsGroupAdmin HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods isGroupAdmin :: UserID -> GroupID -> HasqlSession Bool Source # | |
| HasIsGroupAdmin HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods isGroupAdmin :: UserID -> GroupID -> HasqlTransaction Bool Source # | |
class Monad m => HasIsSuperAdmin (m :: Type -> Type) where Source #
Instances
| HasIsSuperAdmin HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods isSuperAdmin :: UserID -> HasqlSession Bool Source # | |
| HasIsSuperAdmin HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods | |
class Monad m => HasExistsDocument (m :: Type -> Type) where Source #
Methods
existsDocument :: DocumentID -> m Bool Source #
Check whether a Document exists in the database.
Instances
| HasExistsDocument HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods | |
| HasExistsDocument HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods existsDocument :: DocumentID -> HasqlTransaction Bool Source # | |
class HasExistsDocument m => HasExistsTextElement (m :: Type -> Type) where Source #
Methods
existsTextElement :: TextElementRef -> m Bool Source #
Check whether a TextElement exists in the database.
Instances
| HasExistsTextElement HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods existsTextElement :: TextElementRef -> HasqlSession Bool Source # | |
| HasExistsTextElement HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods existsTextElement :: TextElementRef -> HasqlTransaction Bool Source # | |
class HasExistsTextElement m => HasExistsTextRevision (m :: Type -> Type) where Source #
Methods
existsTextRevision :: TextRevisionRef -> m Bool Source #
Check whether a TextRevision exists in the database.
Instances
| HasExistsTextRevision HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods existsTextRevision :: TextRevisionRef -> HasqlSession Bool Source # | |
| HasExistsTextRevision HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods existsTextRevision :: TextRevisionRef -> HasqlTransaction Bool Source # | |
class HasExistsDocument m => HasExistsTreeRevision (m :: Type -> Type) where Source #
Methods
existsTreeRevision :: TreeRevisionRef -> m Bool Source #
Check whether a TreeRevision exists in the database.
Instances
| HasExistsTreeRevision HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods existsTreeRevision :: TreeRevisionRef -> HasqlSession Bool Source # | |
| HasExistsTreeRevision HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods existsTreeRevision :: TreeRevisionRef -> HasqlTransaction Bool Source # | |
class HasCheckPermission m => HasGetTextElement (m :: Type -> Type) where Source #
Methods
getTextElement :: TextElementID -> m (Maybe TextElement) Source #
Get a TextElement from the database.
Instances
| HasGetTextElement HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods getTextElement :: TextElementID -> HasqlTransaction (Maybe TextElement) Source # | |
class (HasCheckPermission m, HasIsGroupAdmin m, HasIsSuperAdmin m) => HasGetDocument (m :: Type -> Type) where Source #
Methods
getDocument :: DocumentID -> m (Maybe Document) Source #
Get a Document from the database by id.
getDocuments :: UserID -> m (Vector Document) Source #
Get all Documents from the database visible by the user.
getDocumentsBy :: Maybe UserID -> Maybe GroupID -> m (Vector Document) Source #
Get all Documents from the database meeting the given constraints.
Instances
| HasGetDocument HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods getDocument :: DocumentID -> HasqlSession (Maybe Document) Source # getDocuments :: UserID -> HasqlSession (Vector Document) Source # getDocumentsBy :: Maybe UserID -> Maybe GroupID -> HasqlSession (Vector Document) Source # | |
| HasGetDocument HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods getDocument :: DocumentID -> HasqlTransaction (Maybe Document) Source # getDocuments :: UserID -> HasqlTransaction (Vector Document) Source # getDocumentsBy :: Maybe UserID -> Maybe GroupID -> HasqlTransaction (Vector Document) Source # | |
class (HasCheckPermission m, HasExistsTreeRevision m) => HasGetTreeRevision (m :: Type -> Type) where Source #
Methods
getTreeRevision :: TreeRevisionRef -> m (Maybe (TreeRevision TextElement)) Source #
Get a TreeRevision by its ref from the database.
Instances
| HasGetTreeRevision HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods getTreeRevision :: TreeRevisionRef -> HasqlSession (Maybe (TreeRevision TextElement)) Source # | |
| HasGetTreeRevision HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods getTreeRevision :: TreeRevisionRef -> HasqlTransaction (Maybe (TreeRevision TextElement)) Source # | |
class (HasCheckPermission m, HasExistsTextRevision m) => HasGetTextElementRevision (m :: Type -> Type) where Source #
Methods
getTextElementRevision :: TextRevisionRef -> m (Maybe TextElementRevision) Source #
Get a TextElementRevision by the revisions ref from the database.
Instances
| HasGetTextElementRevision HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods getTextElementRevision :: TextRevisionRef -> HasqlSession (Maybe TextElementRevision) Source # | |
| HasGetTextElementRevision HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods getTextElementRevision :: TextRevisionRef -> HasqlTransaction (Maybe TextElementRevision) Source # | |
class (HasCheckPermission m, HasExistsTextElement m) => HasGetTextHistory (m :: Type -> Type) where Source #
Methods
Arguments
| :: TextElementRef | the text element |
| -> Maybe UTCTime | time frame begin |
| -> Maybe UTCTime | time frame end |
| -> Int64 | limit |
| -> m TextRevisionHistory | chronological overview of revisions |
Get a chronological overview of TextElement revisions within the specified
time frame.
Instances
| HasGetTextHistory HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods getTextHistory :: TextElementRef -> Maybe UTCTime -> Maybe UTCTime -> Int64 -> HasqlSession TextRevisionHistory Source # | |
class (HasCheckPermission m, HasExistsDocument m) => HasGetTreeHistory (m :: Type -> Type) where Source #
Methods
Arguments
| :: DocumentID | the document |
| -> Maybe UTCTime | time frame end |
| -> Int64 | limit |
| -> m TreeRevisionHistory | chronological overview of revisions |
Get a chronological overview of Tree revisions within the specified
time frame.
TODO: take same parameters as "Docs.Database.getTextHistory"
Instances
| HasGetTreeHistory HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods getTreeHistory :: DocumentID -> Maybe UTCTime -> Int64 -> HasqlSession TreeRevisionHistory Source # | |
class (HasCheckPermission m, HasExistsDocument m) => HasGetDocumentHistory (m :: Type -> Type) where Source #
Methods
Arguments
| :: DocumentID | the document |
| -> Maybe UTCTime | time frame end |
| -> Int64 | limit |
| -> m DocumentHistory | chronological overview of revisions |
Get a chronological overview of revisions of both kinds
(Tree and TextElement) for a document within the specified time frame.
TODO: take same parameters as "Docs.Database.getTextHistory"
Instances
| HasGetDocumentHistory HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods getDocumentHistory :: DocumentID -> Maybe UTCTime -> Int64 -> HasqlSession DocumentHistory Source # | |
class HasIsGroupAdmin m => HasCreateDocument (m :: Type -> Type) where Source #
Methods
createDocument :: Text -> GroupID -> UserID -> m Document Source #
Create a new Document in the database.
Instances
| HasCreateDocument HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods createDocument :: Text -> GroupID -> UserID -> HasqlSession Document Source # | |
| HasCreateDocument HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods createDocument :: Text -> GroupID -> UserID -> HasqlTransaction Document Source # | |
class (HasCheckPermission m, HasExistsDocument m) => HasCreateTextElement (m :: Type -> Type) where Source #
Methods
createTextElement :: DocumentID -> TextElementKind -> TextElementType -> m TextElement Source #
Create a new TextElement in the database.
Instances
| HasCreateTextElement HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods createTextElement :: DocumentID -> TextElementKind -> TextElementType -> HasqlSession TextElement Source # | |
| HasCreateTextElement HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods createTextElement :: DocumentID -> TextElementKind -> TextElementType -> HasqlTransaction TextElement Source # | |
class (HasCheckPermission m, HasExistsTextElement m, HasNow m) => HasCreateTextRevision (m :: Type -> Type) where Source #
Methods
Arguments
| :: TextRevisionID | id of the text revision |
| -> Text | new text |
| -> Vector CommentAnchor | new comment anchors |
| -> m TextRevision | updated text revision |
Update text and CommentAnchors for a TextRevision.
Arguments
| :: UserID | the user who should own the new revision |
| -> TextElementRef | the text element |
| -> Text | the content of the new revision |
| -> Vector CommentAnchor | comment anchors for the revision |
| -> m TextRevision | the newly created |
Create a new TextRevision in the database.
getLatestTextRevisionID :: TextElementRef -> m (Maybe TextRevisionID) Source #
Get the id of the latest TextElement revision.
updateLatestTitle :: TextElementID -> Text -> m () Source #
currently only intended as a temporary solution
TODO: Kann das weg? Ich glaub, das kann weg.
Instances
| HasCreateTextRevision HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods updateTextRevision :: TextRevisionID -> Text -> Vector CommentAnchor -> HasqlTransaction TextRevision Source # createTextRevision :: UserID -> TextElementRef -> Text -> Vector CommentAnchor -> HasqlTransaction TextRevision Source # getLatestTextRevisionID :: TextElementRef -> HasqlTransaction (Maybe TextRevisionID) Source # updateLatestTitle :: TextElementID -> Text -> HasqlTransaction () Source # | |
class (HasCheckPermission m, HasExistsDocument m) => HasCreateTreeRevision (m :: Type -> Type) where Source #
Methods
Arguments
| :: UserID | the user who should own the new revision |
| -> DocumentID | the document the revision belongs to |
| -> Node TextElementID | the root node for the tree of the new revision |
| -> m (TreeRevision TextElementID) | the newly created revision |
Create a new TreeRevision in the database.
existsTextElementInDocument Source #
Arguments
| :: DocumentID | the document to check whether a |
| -> m (TextElementID -> Bool) | the function to check the existence of the |
Obtains a function to check whether a TextElementID belongs to the
document.
Instances
| HasCreateTreeRevision HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods createTreeRevision :: UserID -> DocumentID -> Node TextElementID -> HasqlTransaction (TreeRevision TextElementID) Source # existsTextElementInDocument :: DocumentID -> HasqlTransaction (TextElementID -> Bool) Source # | |
class (HasCheckPermission m, HasExistsDocument m, HasExistsTextElement m) => HasGetComments (m :: Type -> Type) where Source #
Methods
getComments :: TextElementRef -> m (Vector Comment) Source #
Get all Comments for a TextElement.
Instances
| HasGetComments HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods getComments :: TextElementRef -> HasqlSession (Vector Comment) Source # | |
class (HasCheckPermission m, HasExistsComment m) => HasCreateComment (m :: Type -> Type) where Source #
Methods
Arguments
| :: UserID | the user who intends to create the |
| -> TextElementID | the id of the |
| -> Text | the content of the |
| -> m Comment | the newly created |
Creats a new Comment in the database.
resolveComment :: CommentID -> m () Source #
Mark a Comment as resolved.
Arguments
| :: UserID | the user who intends to create the reply |
| -> CommentID | the id of the |
| -> Text | the content of the replys message |
| -> m Message | the newly created reply's |
Create a new reply to an existing Comment.
Instances
| HasCreateComment HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods createComment :: UserID -> TextElementID -> Text -> HasqlTransaction Comment Source # resolveComment :: CommentID -> HasqlTransaction () Source # createReply :: UserID -> CommentID -> Text -> HasqlTransaction Message Source # | |
class HasExistsTextElement m => HasExistsComment (m :: Type -> Type) where Source #
Methods
existsComment :: CommentRef -> m Bool Source #
Check whether a Comment exists in the database.
Instances
| HasExistsComment HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods existsComment :: CommentRef -> HasqlTransaction Bool Source # | |
class HasIsSuperAdmin m => HasGetLogs (m :: Type -> Type) where Source #
Methods
Arguments
| :: Maybe UTCTime | offset |
| -> Int64 | limit |
| -> m (Vector LogMessage) | log messages |
Get all log messages within the specified time frame.
Instances
| HasGetLogs HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods getLogs :: Maybe UTCTime -> Int64 -> HasqlSession (Vector LogMessage) Source # | |
class Monad m => HasLogMessage (m :: Type -> Type) where Source #
Methods
Arguments
| :: ToJSON v | |
| => Severity | the severity of the event |
| -> Maybe UserID | the user who caused the event |
| -> Scope | the scope the event occured in |
| -> v | the content of the message |
| -> m LogMessage | the logged message |
Log a message to the database.
Instances
| HasLogMessage HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods logMessage :: ToJSON v => Severity -> Maybe UserID -> Scope -> v -> HasqlSession LogMessage Source # | |
| HasLogMessage HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods logMessage :: ToJSON v => Severity -> Maybe UserID -> Scope -> v -> HasqlTransaction LogMessage Source # | |
class HasExistsDocument m => HasGetRevisionKey (m :: Type -> Type) where Source #
Methods
getRevisionKey :: RevisionRef -> m (Maybe RevisionKey) Source #
Get the RevisionKey for a RevisionRef.
The RevisionKey is a RevisionRef with additional information on
whether the referenced revision is a TextElement revision or a
Tree revision.
Instances
| HasGetRevisionKey HasqlSession Source # | |
Defined in Docs.Hasql.Database Methods getRevisionKey :: RevisionRef -> HasqlSession (Maybe RevisionKey) Source # | |
| HasGetRevisionKey HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods getRevisionKey :: RevisionRef -> HasqlTransaction (Maybe RevisionKey) Source # | |
class (HasCheckPermission m, HasExistsTextElement m) => HasDraftTextRevision (m :: Type -> Type) where Source #
Methods
createDraftTextRevision Source #
Arguments
| :: UserID | the user who should own the draft |
| -> TextElementRef | the |
| -> TextRevisionID | the |
| -> Text | the content of the creaft in statu nascendi |
| -> Vector CommentAnchor | comment anchors for the draft |
| -> m DraftRevision | the newly created draft |
Create a new text revision draft in the database.
getDraftTextRevision :: UserID -> TextElementRef -> m (Maybe DraftRevision) Source #
Get a users DraftRevision for a TextElement if it exists.
deleteDraftTextRevision :: UserID -> TextElementRef -> m () Source #
Delete a users DraftRevision for a TextElement.
Instances
| HasDraftTextRevision HasqlTransaction Source # | |
Defined in Docs.Hasql.Database Methods createDraftTextRevision :: UserID -> TextElementRef -> TextRevisionID -> Text -> Vector CommentAnchor -> HasqlTransaction DraftRevision Source # getDraftTextRevision :: UserID -> TextElementRef -> HasqlTransaction (Maybe DraftRevision) Source # deleteDraftTextRevision :: UserID -> TextElementRef -> HasqlTransaction () Source # | |