小编Ser*_*nev的帖子

如何获取 Prisma 类的所有字段?

我在 Prisma 模式中有这两个表:

model Accounts {
  id Int @id @default(autoincrement())
  name String @db.VarChar(100)
  description String? @db.VarChar(255)
  timeZone Int @default(0)
  tableBusinessApplication AccountsBusinessApplications[]
}

model AccountsBusinessApplications {
  id Int @id @default(autoincrement())
  account Accounts @relation(fields: [accountId], references: [id])
  accountId Int
  name String @db.VarChar(100)
  identification String @db.VarChar(100)
  secretKey String @db.VarChar(32)
}
Run Code Online (Sandbox Code Playgroud)

我有以下代码:

const name = 'Accounts'
prisma[name].findFirst({
  where: { id: 1}
}).then(result => { console.log(result) })
Run Code Online (Sandbox Code Playgroud)

结果我有:

{
  id: 1,
  name: 'test',
  description: 'test description',
  timeZone: 0
}
Run Code Online (Sandbox Code Playgroud)

但我在里面没有看到“ tableBusinessApplication ”。如果我只知道一级名称“ Accounts ”并且无法在查询中使用“ Include …

database back node.js prisma

3
推荐指数
1
解决办法
5221
查看次数

标签 统计

back ×1

database ×1

node.js ×1

prisma ×1