Category

final class Category : Model

Categories are used to organize Twit-arr Forums into a managable structure. All Forums 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.

Properties

  • id

    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?

Relations

Initialization