Skip to content

@omit doesn't omit the field when using relationship INCLUDE #984

Closed
@dikyarga

Description

@dikyarga

Description and expected behavior

Background:

I'm following this article: https://zenstack.dev/blog/soft-delete-real to implement soft-delete

Problem

if we get data directly from the model itself db.product.findMany(), it does omit deleted field. But, if we get the data thru include e.g, db.category.findFirst({include: {products: true}}), it doesn't omit the deleted field.

expected behavior

my expectation was to also exclude the field when using relationships.

schema example (simplified):

model Product {
  id String @id @default(cuid())
  category Category @relation(fields: [categoryId], references: [id])
  categoryId String

  deleted Int @default(0) @omit
  @@deny('read', deleted != 0)
}

model Category {
  products Product[]
}

Screenshots
CleanShot 2024-02-06 at 20 43 48@2x

Environment (please complete the following information):

  • ZenStack version: [1.8.1]
  • Prisma version: [5.7.1]
  • Database type: [SQLite]

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions