Documentation ¶
Overview ¶
Package database provides the internal database of DiscussionGo! The access times of topics are in an other module (accesstimes). This allows for both data sources to be operated separately.
Index ¶
- func AddInvitation(user string) (string, error)
- func AddPost(topicID, user, content string) (string, error)
- func AddTopic(name, creator string) (string, error)
- func AddUser(user, pw string, admin bool) error
- func DeletePost(topicID, ID string) error
- func DeleteTopic(ID string) error
- func DeleteUser(user string) (int64, error)
- func EditPassword(user, pw string) error
- func GetInvitationCreator(id string) (string, error)
- func GetInvitations(user string) ([]string, error)
- func GetLastUpdateTopicPost() int64
- func InitDB(config string) error
- func IsAdmin(user string) (bool, error)
- func ModifyLastSeen(user string) error
- func RemoveAllInvitation() error
- func RemoveInvitation(id string) error
- func RenameTopic(ID string, newName string) error
- func SetAdmin(user string, admin bool) error
- func SetComment(user string, comment string) error
- func SetInvitedby(user, invitedby string, direct bool) error
- func SetLastUpdateTopicPost()
- func TestInvitation(id string) (bool, error)
- func TopicModifyTime(ID string) error
- func TopicSetClosed(ID string, closed bool) error
- func TopicSetPinned(ID string, pinned bool) error
- func UserExists(user string) (bool, error)
- func VerifyUser(user, pw string) (bool, error)
- type Post
- type Topic
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddInvitation ¶
AddInvitation adds a new invitation from a user. It returns the ID of the new invitation.
func AddTopic ¶
AddTopic adds a new topic to the database. The modification time is set to the current time.
func AddUser ¶
AddUser adds a new user to the database. Admin status is automatically set to the provided value. Returns an error if the user alreasy exist.
func DeletePost ¶
DeletePost removes a post completely from the database. This action can not be undone.
func DeleteTopic ¶
DeleteTopic removes a topic and all associated posts from the database. This action can not be undone.
func DeleteUser ¶
DeleteUser removes a user and all associated information from the database. It returns the number of removed informations. It can not be reverted.
func EditPassword ¶
EditPassword changes the password of a user. Returns an error if the user does not exist.
func GetInvitationCreator ¶
GetInvitationCreator returns the creator of an invitation (identified by ID).
func GetInvitations ¶
GetInvitations returns all invitations (identified by ID) created by a user.
func GetLastUpdateTopicPost ¶
func GetLastUpdateTopicPost() int64
GetLastUpdateTopicPost returns the time of the last update of any post/topic as an int64 in nano seconds.
func InitDB ¶
InitDB initialises the database. Must be called before any other function. This stub will return an error if no build tags are set.
func IsAdmin ¶
IsAdmin returns whether a user is administrator. Returns an error if the user does not exist.
func ModifyLastSeen ¶
ModifyLastSeen sets the 'last seen' status of a user to the current time. Returns an error if the user does not exist.
func RemoveAllInvitation ¶
func RemoveAllInvitation() error
RemoveAllInvitation removes all invitations from the database, making all invalid.
func RemoveInvitation ¶
RemoveInvitation returns the invitation (identified by ID) from the database. It is no longer valid.
func RenameTopic ¶
RenameTopic renames a topic. It does affect the modification time.
func SetAdmin ¶
SetAdmin sets whether a user is administrator. Returns an error if the user does not exist.
func SetComment ¶
SetComment updates the comment of a user. Returns an error if the user does not exist.
func SetInvitedby ¶
SetInvitedby sets which user invited the user. Returns an error if the target user does not exist. It does not check if the invitor does not exists. This is intentioal, allowing 'pseudo user' as an inviter.
func SetLastUpdateTopicPost ¶
func SetLastUpdateTopicPost()
SetLastUpdateTopicPost updates the time of the last update of any post/topic. It is internally called by the functions of the database package. You only need to call it if you manually update a post (e.g. by adding data to the post which is stored in an other package).
func TestInvitation ¶
TestInvitation returns whether an invitation is valid.
func TopicModifyTime ¶
TopicModifyTime sets the modification time of a topic to the current time.
func TopicSetClosed ¶
TopicSetClosed sets the 'closed' property of a topic to the given value. It does not affect the modification time.
func TopicSetPinned ¶
TopicSetPinned sets the 'pinned' property of a topic to the given value. It does not affect the modification time.
func UserExists ¶
UserExists returns whether the user is known in the database. It only returns an error if a communication problem with the database occured. In all other cases, the bool signals whether the user is known.
func VerifyUser ¶
VerifyUser returns whether the user exists and the provided password is correct. It should only return an error on communication problems with the database, but not if any checks fail.
Types ¶
type Post ¶
Post represents a post in the database.
func GetPostsByUser ¶
GetPostsByUser returns all posts of a user from the database.
func GetSinglePost ¶
GetSinglePost returns the post associated with the given ID.
type Topic ¶
type Topic struct { ID string Name string Creator string Created time.Time LastModified time.Time Closed bool Pinned bool }
Topic represents a topic in the database.
func GetTopicsByUser ¶
GetTopicsByUser returns all topics belonging to a user currently saved in the database.
type User ¶
type User struct { Name string Admin bool Comment string InvidedBy string InvitationDirect bool LastSeen time.Time }
User represents a user in the database. For security reasons, the password and the salt is not included.
func GetAllUser ¶
GetAllUser returns all user currently known to the database.