It is not possible to make nested migrations to Prisma

Viewed 42

I'm trying to create my first API on nets.js/prisma/postgresql But I had difficulties describing the models in the prisma I want that on request https://my-api/seasons the server gave a response of the form:

[
  {
    "Season1": {
      "name": "Season 1",
      "series": {
        "seria1": {
          "title": "text 1 1",
          "url": "url 1 1",
          "date": "date 1 1"
        },
        "seria2": {
          "title": "text 1 2",
          "url": "url 1 2",
          "date": "date 1 2"
        }
      }
    }
  },
  {
    "Season2": {
      "name": "Season 2",
      "series": {
        "seria1": {
          "title": "text 2 1",
          "url": "url 2 1",
          "date": "date 2 1"
        },
        "seria2": {
          "title": "text 2 2",
          "url": "url 2 2",
          "date": "date 2 2"
        }
      }
    }
  }
]

To make it clearer and clearer:

json data example

json data example

This is a simplified kind of migration that doesn't work for me How can I make the same level of nesting using Prisma migration as I described above?

model Seasons {
  id       Int    @id @default(autoincrement())
  name     Season @relation(fields: [seasonId], references: [id])
  seasonId Int
}

model Season {
  id      Int       @id @default(autoincrement())
  name    String    @db.VarChar(40)
  Seasons Seasons[]
}
0 Answers
Related