controller

package
v0.0.0-...-9bca149 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateContent

func CreateContent(coll string, content *model.Content) (*mongo.InsertOneResult, error)

Insert content entry in collection coll with provided Parameters

func CreateContentType

func CreateContentType(ct *model.ContentType) (*mongo.InsertOneResult, error)

Insert content type with provided Parameters in DB

func CreateRole

func CreateRole(r *model.Role) (*mongo.InsertOneResult, error)

Insert role with provided Parameters in DB

func CreateUser

func CreateUser(user *model.User) (*mongo.InsertOneResult, error)

Insert user with provided Parameters in DB

func DeleteContent

func DeleteContent(coll string, id string) (*mongo.DeleteResult, error)

Delete content entry provided ID in DB

func DeleteContentType

func DeleteContentType(id string) (*mongo.DeleteResult, error)

Delete content type with provided ID in DB

func DeleteRole

func DeleteRole(id string) (*mongo.DeleteResult, error)

Delete role with provided filter in DB

func DeleteRoleFromPermissions

func DeleteRoleFromPermissions(rID primitive.ObjectID, ct *model.ContentType) (*mongo.UpdateResult, error)

Delete one role from content type permissions.

func DeleteRoleFromUser

func DeleteRoleFromUser(rID primitive.ObjectID, user *model.User) (*mongo.UpdateResult, error)

Delete only one role from user.

func DeleteUser

func DeleteUser(id string) (*mongo.DeleteResult, error)

Delete user with provided ID in DB

func GetContent

func GetContent(coll string, filter interface{}) ([]*model.Content, error)

Return all content entries from collection coll that match the filter

func GetContentById

func GetContentById(coll string, id string) (*model.Content, error)

Return Content from collection coll with provided ID

func GetContentEntry

func GetContentEntry(coll string, filter interface{}) (*model.Content, error)

Return a single content entry from collection coll that matches the filter. Filter must be structured in bson types.

func GetContentType

func GetContentType(filter interface{}) (*model.ContentType, error)

Return a single ContentType that matches the filter

func GetContentTypeByCollection

func GetContentTypeByCollection(coll string) (*model.ContentType, error)

Returns a content type basing on a collection

func GetContentTypeById

func GetContentTypeById(id string) (*model.ContentType, error)

Return a single ContentType with provided ID

func GetContentTypes

func GetContentTypes(filter interface{}) ([]*model.ContentType, error)

Return all ContentTypes that match the filter

func GetCustomFields

func GetCustomFields(coll string) (map[string]interface{}, error)

Returns the Custom fields of a contenttype as map Takes the collection of a content type as input

func GetRole

func GetRole(filter interface{}) (*model.Role, error)

Returns first role that matches the filter

func GetRoleById

func GetRoleById(id string) (*model.Role, error)

Returns the role Object with provided ID

func GetRoleByName

func GetRoleByName(name string) (*model.Role, error)

Returns the role with provided role name

func GetRoleByTag

func GetRoleByTag(tag string) (*model.Role, error)

Return the role with provided role tag

func GetRoleNames

func GetRoleNames(roleIDs []primitive.ObjectID) ([]string, error)

Returns slice of role names of provided role ObjectsIDs

func GetRoles

func GetRoles(filter interface{}) ([]*model.Role, error)

Return all roles that match the filter

func GetUser

func GetUser(filter interface{}) (*model.User, error)

Return a single user that matches the filter

func GetUserByEmail

func GetUserByEmail(e string) (*model.User, error)

Return a single user that matches the email input

func GetUserById

func GetUserById(id string) (*model.User, error)

Return a single user that matches the id input

func GetUserByUsername

func GetUserByUsername(u string) (*model.User, error)

Return a single user that matches the username input

func GetUserPasswordHash

func GetUserPasswordHash(id string) (string, error)

Return hashed Password of User with provided ID

func GetUsers

func GetUsers(filter interface{}) ([]*model.User, error)

Return all users from DB with provided Filter

func InitAdminUser

func InitAdminUser() error

Initialize Users with an admin user

func InitContentTypes

func InitContentTypes() error

Initialize collection ContentTypes with 'blogposts' and 'events'

func InitRoles

func InitRoles() error

Initialize collection roles with 'admin' and 'user'

func IsValidContentCollection

func IsValidContentCollection(coll string) bool

Returns true if the a contenttype with exists, where the `collection` field value is `coll`

func IsValidRole

func IsValidRole(role string) bool

Return true if the a role with given string role name exists

func UpdateContent

func UpdateContent(coll string, id string, input *model.ContentUpdate) (*mongo.UpdateResult, error)

Update content entry in collection coll with provided parameters

func UpdateContentType

func UpdateContentType(id string, input *model.ContentTypeUpdate) (*mongo.UpdateResult, error)

Update content type with provided parameters

func UpdateRole

func UpdateRole(id string, input *model.Role) (*mongo.UpdateResult, error)

Update role with provided parameters

func UpdateUser

func UpdateUser(id string, input *model.UserUpdate) (*mongo.UpdateResult, error)

Update user with provided Parameters in DB

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL