question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ignoreRelatedModels (but include foreign key fields)

See original GitHub issue

Great work on this!

I was thinking of using a generated schema as a starting point for user input validation. In most cases, I would have no use for the relations.

model agedivision {
  id                  Int                   @id @default(autoincrement())
  ageDivName          String               @db.VarChar(30)
  agedivision_athlete agedivision_athlete[]
  athlete             athlete[]
}

Currently produces:

{
  "agedivision": {
    "type": "object",
    "properties": {
      "id": {
        "type": "integer"
      },
      "name": {
        "type": "string"
      },
      "agedivision_athlete": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/agedivision_athlete"
        }
      },
      "athlete": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/athlete"
        }
      }
    }
  }
}

I would have liked:

{
  "agedivision": {
    "type": "object",
    "properties": {
      "id": {
        "type": "integer"
      },
      "name": {
        "type": "string"
      }
    }
  }
}

Foreign keys would be included.

Is this a feature that you have plans for?

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
valentinpalkoviccommented, May 31, 2022

You are already able to also generate the relational scalar fields by enabling it in the settings:

generator jsonSchema {
  provider = "prisma-json-schema-generator"
  keepRelationScalarFields = "true"
}

Then userRoleId will be generated as well. And the only feature you would like to have is to ditch the relation fields. Am I right?

2reactions
valentinpalkoviccommented, May 30, 2022

@Flax95 Thank you for opening up this issue!

Should the relations only be dropped, If they are not available in the schema or always?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exclude models based on a value from another model with no ...
Exclude models based on a value from another model with no foreign key · Why did you not use a ForeignKey in the...
Read more >
Changing Foreign Keys and Navigations - EF Core
Foreign keys are a good way to store and manipulate relationships in the database, but are not very friendly when working with multiple...
Read more >
3 common foreign key mistakes (and how to avoid them)
Foreign key constraints are important to any SQL database, but they can also cause problems if they're not implemented correctly.
Read more >
4. Using Convention and Configuration for Relationships
Code First allows you define relationships without using foreign key properties in your classes. However, some of the confusing behaviors that developers ...
Read more >
Model field reference - Django documentation
Technically, these models are defined in django.db.models.fields , but for ... a ForeignKey . choices is meant for static data that doesn't change...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found