简体   繁体   English

如何使用Prisma在新记录中更新/创建空字段

[英]How do you update/create a null field in a new record with Prisma

I'm setting up permissions for user on a CRUD app, I want to give myself the permission of ADMIN but I can't seem to do it. 我正在为CRUD应用程序上的用户设置权限,我想给自己一个ADMIN的权限,但我似乎无法做到这一点。 I have set up my data type for a user as follows: 我为user设置了我的数据类型,如下所示:

datamodel.graphql : datamodel.graphql

type User {
    id: ID! @unique
    name: String!
    email: String! @unique
    password: String!
    resetToken: String
    resetTokenExpiry: String
    permissions: [Permission]
}

schema.graphql : schema.graphql

type User {
    id: ID!
    name: String!
    email: String!
    permissions: [Permission!]!
}

When using my Prisma console, I can fill out all the fields except for permissions . 使用我的Prisma控制台时,我可以填写 permissions 之外的所有字段。

在此输入图像描述

And when trying to update an existing user's permissions, I can't seem to type anything in that field to update it. 在尝试更新现有用户的权限时,我似乎无法在该字段中键入任何内容来更新它。 Is my schema wrong? 我的架构错了吗?

I believe permission is an enum(I am kinda recognising that schema from the Wes Bos Course). 我相信许可是一个枚举(我有点认识到Wes Bos课程的架构)。

You can add an item to an enum by using the three-dot menu > Add an Item 您可以使用三点菜单>添加项目将项目添加到枚举

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 FaunaDB 中更新记录时,如何在不传入每个字段和子对象的情况下更新一个字段? - When updating a record in FaunaDB, how do I update one field without passing in every field and subobject? PRISMA:如何在 prisma 常规类型中跳过 id 字段? - PRISMA: How to skip id field in prisma regular type? 您如何使用具有多个突变的自定义文件正确地为prisma DB 播种? - How do you correctly seed a prisma DB with a custom file that has multiple mutations? 如何在 Prisma GraphQL 中向 Model 添加字段? - How to add a field to a Model in Prisma GraphQL? graphql 与棱镜使用 where in update func 与关系字段 - graphql with prisma use where in update func with relation field 如何在包含graphql / prisma中的关系的类型上创建查询? - How do I create a query on a type which includes a relation in graphql/prisma? 如何在 prisma2 中创建多对多关系 - How to create many to many relationship in prisma2 如何使用 Prisma 创建 4 级嵌套关系 - How to create 4-level nested relationship with Prisma 如何在prisma查询中创建嵌套连接? - How to create nested connection in prisma query? 如何获取棱柱绑定npm中的总匹配记录数 - how to get the total matched record count in prisma-binding npm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM