ForumReaders

final class ForumReaders : Model

A Pivot holding a siblings relation between a User and a Forum. The pivot tracks how many posts the user has read in the forum.

Properties

  • id

    The ID of the pivot.

    Declaration

    Swift

    @ID
    var id: UUID?
  • The highest postID that the user has read in the forum..

    Declaration

    Swift

    @Field
    var lastPostReadID: Int?
  • TRUE if this forum is favorited by this user.

    Declaration

    Swift

    @Field
    var isFavorite: Bool
  • True if the user has muted this forum and does not want any notifications. Otherwise this field should be NIL, never FALSE. This rule makes searches for forums with no reader pivot (because the user has never read the forum) appear equal to forums the user has read (and created a pivot) but not muted.

    Declaration

    Swift

    @Field
    var isMuted: Bool?
  • 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?

Relationships

Initialization

  • Declaration

    Swift

    init()
  • Initializes a new ForumReaders pivot. The pivot’s readCount gets initialized to 0.

    Declaration

    Swift

    init(_ userID: UUID, _ forum: Forum) throws

    Parameters

    user

    The associated User model.

    forum

    The associated Forum model.