Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define required or not for array fields in the prisma datamodel

What are the differences of followings. when to use a one over the other?

zones: [Zone]
zones: [Zone!]
zones: [Zone]!
zones: [Zone!]!
like image 830
Dulara Malindu Avatar asked Oct 29 '25 07:10

Dulara Malindu


1 Answers

This can be summarised with this table of allowed values based on the definition:

values         | [Zone] | [Zone!] | [Zone]! | [Zone!]! |
--------------------------------------------------------
null           |    ✔   |    ✔    |    X    |     X    |
[]             |    ✔   |    ✔    |    ✔    |     ✔    |
[null]         |    ✔   |    X    |    ✔    |     X    |
["a","b"]      |    ✔   |    ✔    |    ✔    |     ✔    |
["a",null,"c"] |    ✔   |    X    |    ✔    |     X    |

Most of the time, you will need to use [Zone!]! as it ensures that no null values will be found in your array.

like image 104
Errorname Avatar answered Oct 31 '25 09:10

Errorname



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!