Debouncable
protocol Debouncable : Model
If a model implements this, you can pass a new instance to createOrReturnDebounced and it will try to create it, but if a recent row exists by the same creator with the same idempotency key, it will return the existing one.
-
Declaration
Swift
typealias CreatorKeyPath = KeyPath<Self, ParentProperty<Self, User>> -
Declaration
Swift
static var creatorKeyPath: CreatorKeyPath { get } -
Declaration
Swift
typealias IdempotencyKeyKeyPath = KeyPath<Self, OptionalFieldProperty<Self, UUID>> -
Declaration
Swift
static var idempotencyKeyKeyPath: IdempotencyKeyKeyPath { get } -
Declaration
Swift
func hasSamePostContent(as other: Self) -> Bool -
constraintExtension methodDeclaration
Swift
static var constraint: String { get } -
creatorPropertyExtension methodDeclaration
Swift
var creatorProperty: ParentProperty<Self, User> { get } -
creatorFieldKeyExtension methodDeclaration
Swift
static var creatorFieldKey: FieldKey { get } -
idempotencyKeyPropertyExtension methodDeclaration
Swift
var idempotencyKeyProperty: OptionalFieldProperty<Self, UUID> { get } -
idempotencyKeyFieldKeyExtension methodDeclaration
Swift
static var idempotencyKeyFieldKey: FieldKey { get } -
createDebounced(on:Extension method, asynchronous) Attempts to create the given model instance. If it succeeds, return true. If it fails because of the idempotency key constraint, throws AlreadyExistsError. The creator will be eagerly fetched. If it fails for any other reason, rethrow the error.
Declaration
Swift
func createDebounced(on database: Database) async throws
View on GitHub