Documentation ¶
Overview ¶
This package's main job is to build the `where` conditions of SQL. Call `GetQueryScopes` to create a LiteDB instance. This can be converted into a `gorm.DB` instance filled with `where` conditions. Call the functions in `expose.go` to get the whole query result, not just the `where` conditions (via Gorm).
This file contains the exposed methods for `comments_get` package
Index ¶
- func CommentsWithinPage(pageKey string) func(liteDB) liteDB
- func CommentsWithinSite(siteName string) func(liteDB) liteDB
- func CommentsWithinSomeUsers(allAdminIDs []uint) func(liteDB) liteDB
- func CommonScope(user entity.User) func(liteDB) liteDB
- func ConvertGormScopes(funcs ...func(liteDB) liteDB) []func(*gorm.DB) *gorm.DB
- func FindComments(dao *dao.Dao, opts QueryOptions, pg FindOptions) ([]entity.CookedComment, int64, int64)
- func GetQueryScopes(dao *dao.Dao, opts QueryOptions) func(liteDB) liteDB
- func GetSortSQL(scope Scope, sortBy SortRule) string
- func NoPending(allowUserID ...uint) func(db liteDB) liteDB
- func OnlyRoot() func(db *gorm.DB) *gorm.DB
- func PageScopeQuery(payload PageScopePayload, opts PageScopeOpts) func(liteDB) liteDB
- func SearchScope(dao *dao.Dao, keywords string) func(d liteDB) liteDB
- func SiteScopeQuery(payload SitePayload, user entity.User) func(liteDB) liteDB
- func UserScopeQuery(payload UserScopePayload, opts UserScopeOpts) func(liteDB) liteDB
- type FindOptions
- type PageScopeOpts
- type PageScopePayload
- type PageScopeTag
- type QueryOptions
- type Scope
- type SitePayload
- type SiteScopeType
- type SortRule
- type UserScopeOpts
- type UserScopePayload
- type UserScopeType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommentsWithinPage ¶
func CommentsWithinPage(pageKey string) func(liteDB) liteDB
func CommentsWithinSite ¶
func CommentsWithinSite(siteName string) func(liteDB) liteDB
func CommentsWithinSomeUsers ¶
func CommentsWithinSomeUsers(allAdminIDs []uint) func(liteDB) liteDB
func ConvertGormScopes ¶
func FindComments ¶
func FindComments(dao *dao.Dao, opts QueryOptions, pg FindOptions) ([]entity.CookedComment, int64, int64)
Find comments by options
func GetQueryScopes ¶
func GetQueryScopes(dao *dao.Dao, opts QueryOptions) func(liteDB) liteDB
Get query scope by params
Please be aware that only `WHERE` conditions are permissible in this function. For `ORDER BY`, `LIMIT`, and `OFFSET`, please utilize separate functions, as this function is invoked in both `Find` and `Count`. `ORDER BY`, `LIMIT`, and `OFFSET` cannot be employed within `Count`. Updated: The `*gorm.DB` had been refactored to `liteDB`, which is a subset of `*gorm.DB`. (only contains `WHERE` conditions)
func PageScopeQuery ¶
func PageScopeQuery(payload PageScopePayload, opts PageScopeOpts) func(liteDB) liteDB
Page Scope
func SearchScope ¶
Filter by search keywords
func SiteScopeQuery ¶
func SiteScopeQuery(payload SitePayload, user entity.User) func(liteDB) liteDB
Site Scope (for message center & admin)
func UserScopeQuery ¶
func UserScopeQuery(payload UserScopePayload, opts UserScopeOpts) func(liteDB) liteDB
User Scope (for message center)
Types ¶
type FindOptions ¶
type PageScopeOpts ¶
type PageScopeOpts struct {
AdminUserIDs []uint
}
type PageScopePayload ¶
type PageScopePayload struct { Tags []PageScopeTag SiteName string PageKey string }
type QueryOptions ¶
type QueryOptions struct { User entity.User Scope Scope PagePayload PageScopePayload UserPayload UserScopePayload SitePayload SitePayload SortBy SortRule Search string }
type SitePayload ¶
type SitePayload struct { Type SiteScopeType SiteName string }
type SiteScopeType ¶
type SiteScopeType string
Site Scope Query Tag
const ( SiteAll SiteScopeType = "all" SitePending SiteScopeType = "pending" )
type UserScopeOpts ¶
type UserScopePayload ¶
type UserScopePayload struct {
Type UserScopeType
}
type UserScopeType ¶
type UserScopeType string
User Scope Query Tag
const ( UserAll UserScopeType = "all" UserMentions UserScopeType = "mentions" UserMine UserScopeType = "mine" UserPending UserScopeType = "pending" )
Click to show internal directories.
Click to hide internal directories.