Skip to content

[Feature Request] Support for auth() in @default annotation #310

@bvkimball

Description

@bvkimball

Is your feature request related to a problem? Please describe.
If i already set the UserId when creating the EnhancedPrisma it would be nice not have to pass an additonal argument around for the user or session to ensure a field is populated with the right value.

Describe the solution you'd like

model Post {
    id String @id
    title String @length(1, 100)
    author User @relation(fields: [authorId], references: [id])
+    authorId String @default(auth().id)

    @@allow('update', author == auth() && future().author == author)
}

Additional features that would be nice might be using other fields related to the user.

model Post {
    id String @id
    title String @length(1, 100)
    author User @relation(fields: [authorId], references: [id])
    authorId String @default(auth().id)

+   tenantId String  @default(auth().tenantId)

    @@allow('update', author == auth() && future().author == author)
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions