89 Replies
@Kuhave…can you explain why :user will not work even if i m importing it from client only
could you please attach your error screenshots here?
There's a difference between
null
and Prisma.JsonNull
.
with your schema, set your data as attribute:null
means 'on database, attribute column has no value'(= db null, like you schema's 'name' column can have null value).
but set your data as attribute:Prisma.JsonNull
means 'on datbase, attribute column has value, with json value null'.
and i suggested below codes to work on your case:
Read this docs can help your understanding much more: https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/working-with-json-fields#using-null-valuesWorking with Json fields (Concepts) | Prisma Documentation
How to read, write, and filter by Json fields.
![No description](https://cdn.answeroverflow.com/1265330645249294478/image.png)
@Kuhave i m still confused
If i m giving : User
Why it s having problem…
I imported User from client only
And client is generated by prisma
did u test my code?
typescript
null
means 'databse Null value(no data)'
and typescript Prisma.JsonNull
means database has value, with JSON value 'null'
Imported
User type has
attribute property, which
JsonValue type.
JsonValue type is
string | number | boolean | JsonObject | JsonArray | null.
Your schema defines
attribute as
Json , which means 'Not Nullable on database'.
so your error happens because
attribute` could not be DB Null value.this image means 'i want to set attribute column to DB null'
![No description](https://cdn.answeroverflow.com/1265334517816889376/image.png)
but this image means 'i want to set attribute column to JSON value null '
![No description](https://cdn.answeroverflow.com/1265334816010801152/image.png)
@kartîk i hope u can understand this behavior.
Yes this helps but tell me one thing
I did attribute : json okay?
So in my schema i m setting attribute as JSON…mean it can also have dbnull?
JsonValue
type is string | number | boolean | JsonObject | JsonArray | null
.
As per this?
This null means json null? Or dbnull?No. to allow DB null value you have to set as this image
![No description](https://cdn.answeroverflow.com/1265341043591741493/image.png)
it means json null
I dont want to allow null
Values
There is no way to distinguish whether a null value in typescript means ‘DB null’ or ‘JSON null’
So the thing is as per my schema my attribute can have json null right?