Documentation ¶
Overview ¶
create.go -- DB queries that create objects
db.go -- Database Connection for Application (moved everything into CRUD letter files for simplicity) >Keeping all DB access functions in this package to keep things clean
delete.go -- DB queries that delete objects
read.go -- DB queries that read objects
update.go -- DB queries that edit objects
Index ¶
- Variables
- func ActivateAccount(user bson.ObjectId) error
- func AddAdmin(oldAdmin, user bson.ObjectId, group string) error
- func AddFriend(friend, user bson.ObjectId) error
- func AddName(user bson.ObjectId, name string) error
- func AddUsername(username string, user bson.ObjectId) error
- func ChangePassword(newPassword string, oldPassword string, user bson.ObjectId) error
- func ChangeUsername(username string, user bson.ObjectId) error
- func CheckGroup(group string) (*models.Group, error)
- func CreateGroup(group string, user bson.ObjectId, private bool) error
- func CreateHeadPost(author, body, content, contentType string, authorId bson.ObjectId) *models.Post
- func CreateNotification(id bson.ObjectId, link, text string) error
- func CreatePost(authorId, thread bson.ObjectId, responseTo []bson.ObjectId, ...) (*models.Post, error)
- func CreateThread(group string, anonymous bool, post *models.Post) error
- func CreateUser(email, username, password string) (string, error)
- func DeleteGroup(group string, user bson.ObjectId) error
- func DeletePost(postID, userID bson.ObjectId) error
- func DeleteThread(threadID, userID bson.ObjectId) error
- func DeleteUser(user bson.ObjectId) error
- func EditPost(text string, post, user bson.ObjectId) error
- func GetFriends(author string) ([]bson.ObjectId, error)
- func GetFriendsById(author bson.ObjectId) ([]bson.ObjectId, error)
- func GetFriendsJoined(id bson.ObjectId) ([]string, error)
- func GetGroup(group string, page int) ([]models.Mthread, error)
- func GetGroupInfo(grp string) (*models.GroupInfo, error)
- func GetIdFromEmail(email string) string
- func GetIdFromUsername(username string) string
- func GetNotifications(userId bson.ObjectId) ([]models.Notification, error)
- func GetPermission(group string, user string) *models.Permission
- func GetPopularPosts(id string, skip int) (*models.PopularPosts, error)
- func GetSaved(userId bson.ObjectId) ([]models.Mthread, error)
- func GetThread(threadID bson.ObjectId) (*models.ResThread, error)
- func GetThreadParent(thread string) string
- func GetThreadSize(thread string) int
- func GetUser(user string) (*models.GetUser, error)
- func GetUsername(id bson.ObjectId) string
- func GroupExists(group string) bool
- func IsMember(group string, user string) bool
- func LoginCheck(email, hashword string) (string, bool)
- func RemoveAdmin(oldAdmin, user bson.ObjectId, group string) error
- func RemoveFriend(friend, user bson.ObjectId) error
- func RemoveUser(user bson.ObjectId) error
- func RemoveUsername(username string, user bson.ObjectId) error
- func RequestFriend(user bson.ObjectId, username, friend string) error
- func SaveThread(mthread, user bson.ObjectId) error
- func SearchGroups(str string) ([]string, error)
- func SearchThreads(id string, str string, page int) ([]models.Mthread, error)
- func SearchUsers(str string) ([]string, error)
- func UnsaveThread(thread, user bson.ObjectId) error
Constants ¶
This section is empty.
Variables ¶
var Connection *mgo.Session
Functions ¶
func ActivateAccount ¶
[UPDATE] activates account (when email is verified)
func AddUsername ¶
[UPDATE] adds username for a given uid
func ChangePassword ¶
[UPDATE] changes password for a given uid
func ChangeUsername ¶
[UPDATE] changes username for a given uid
func CheckGroup ¶
[READ] gets group info -- meta info about group from group collection
func CreateGroup ¶
[CREATE] creates a group, rather, reserves a namespace for a group
func CreateHeadPost ¶
[CREATE] creates a head post for a given thread -- leave thread id unset
func CreateNotification ¶
[CREATE] creates a notification for the Id
func CreatePost ¶
func CreatePost(authorId, thread bson.ObjectId, responseTo []bson.ObjectId, author, body, content, contentType string) (*models.Post, error)
[CREATE] creates a post for a given thread
func CreateThread ¶
[CREATE] creates a thread from a struct of a given JSON -- also creates an mthread for each location
func CreateUser ¶
[CREATE] creates user in the Database with given email, username, and hashed password
func DeleteGroup ¶
[DELETE] remove a thread
func DeleteThread ¶
[DELETE] remove a thread
func DeleteUser ¶
[UPDATE] deletes a user's account (in reality, updates 'deleted' to 'true')
func GetFriends ¶
[READ] gets user's friends -- resolving "joins"
func GetFriendsById ¶
[READ] gets user's friends -- resolving "joins"
func GetFriendsJoined ¶
[READ] gets a user's friends -- in a string slice format
func GetGroupInfo ¶
[READ] get metadata about group
func GetIdFromEmail ¶
[READ] gets user data -- posts, watchlist, thread likes, friends -- just returns what we need
func GetIdFromUsername ¶
[READ] gets user data -- posts, watchlist, thread likes, friends -- just returns what we need
func GetNotifications ¶
[READ]
func GetPermission ¶
[READ] checks if user is a member of a group
func GetPopularPosts ¶
[READ] kinda like getting a thread, but it's just the most popular posts (8 of them)
func GetThreadParent ¶
[READ] returns group that the given thead (hex string) belongs to
func GetThreadSize ¶
[READ] get a thread's length (how many posts are in a thread)
func GetUser ¶
[READ] gets user data -- posts, watchlist, thread likes, friends -- just returns what we need
func LoginCheck ¶
[READ] compares the user & hashed password given to the one in the DB
func RemoveAdmin ¶
[UPDATE] Removes admins, only the author can do this
func RemoveUser ¶
[DELETE] actually deletes a user (for dev use only!)
func RemoveUsername ¶
[UPDATE] removes username for a given uid -- musn't be username
func SaveThread ¶
[UPDATE] pushes a thread to a user's watchlist
func SearchGroups ¶
[READ] searches groups for match
func SearchThreads ¶
[READ] search posts text index for a given string
func SearchUsers ¶
[READ] searches usernames and names for match -- EXACT
func UnsaveThread ¶
[UPDATE] removes a thread from a user's watchlist
Types ¶
This section is empty.