Category
final class Category : Model
Categories are used to organize Twit-arr Forum
s into a managable structure. All Forum
s
belong to a single Category
.
Each Category
has a minimum userAccessLevel required to view the Category or view forums in the Category.
Each Category
also has a minimum userAccessLevel required to create new forums in the Category.
See
See Also: CategoryData the DTO for returning info on Categories.See
See Also: CreateCategorySchema the Migration for creating the Category table in the database.-
Declaration
Swift
static let schema: String
-
The category’s ID.
Declaration
Swift
@ID var id: UUID?
-
The title of the category.
Declaration
Swift
@Field var title: String
-
A short string describing what the Category is for. Color commentary for the category.
Declaration
Swift
@Field var purpose: String
-
TRUE if this category holds forums for Events.
Declaration
Swift
@Field var isEventCategory: Bool
-
Minimum access level to view posts in this category. Usually set to
.quarantined
. But, a category reserved for moderators only could have this set to.moderator
.Declaration
Swift
@Enum var accessLevelToView: UserAccessLevel
-
Minimum access level to create threads in this category. Usually set to
.verified
. Setting this to a value less than verified won’t work as those users cannot create any content. This setting does not govern posting in existing threads. An admin could create a thread in an admin-only forum and leave it unlocked so that anyone that can see the thread can post in it. Or, they could lock the thread, preventing posting.Declaration
Swift
@Enum var accessLevelToCreate: UserAccessLevel
-
If non-nil, the UserRoleType that a User is required to posess in order to view items in this category. This test is bypassed for Moderator users. For everyone else, both the Role test and the accessLevel test must pass in order to view.
Declaration
Swift
@OptionalEnum var requiredRole: UserRoleType?
-
The number of forums containted in this Category. Should always be equal to forums.count.
Declaration
Swift
@Field var forumCount: Int32
-
Timestamp of the model’s creation, set automatically.
Declaration
Swift
@Timestamp var createdAt: Date?
-
Timestamp of the model’s last update, set automatically.
Declaration
Swift
@Timestamp var updatedAt: Date?
-
Timestamp of the model’s soft-deletion, set automatically.
Declaration
Swift
@Timestamp var deletedAt: Date?
-
Declaration
Swift
init()
-
Initializes a new Category.
Declaration
Swift
init( title: String, purpose: String, viewAccess: UserAccessLevel = .quarantined, createForumAccess: UserAccessLevel = .verified, isEventCategory: Bool = false, requiredRole: UserRoleType? = nil )
Parameters
title
The title for the the category.
isRestricted
Whether users can create forums in the category.