File tree Expand file tree Collapse file tree 9 files changed +19
-16
lines changed
document-field-customisation/keystone-server
framework-nextjs-app-directory
framework-nextjs-two-servers/keystone-server
packages/fields-document/src Expand file tree Collapse file tree 9 files changed +19
-16
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ model Post {
2323 id String @id @default (cuid () )
2424 title String @default (" " )
2525 slug String @unique @default (" " )
26- content String @default (" [{ \ " type \ " :\ " paragraph \ " , \ " children \ " : [{ \ " text \ " :\ " \ " }]}] " )
26+ content Json @default (" null " )
2727 publishDate DateTime ? @default (now () )
2828 author User ? @relation (" Post_author " , fields : [authorId ] , references : [id ] )
2929 authorId String ? @map (" author " )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ model Post {
1717 title String @default (" " )
1818 slug String @unique @default (" " )
1919 status String ?
20- content String @default (" [{ \ " type \ " :\ " paragraph \ " , \ " children \ " : [{ \ " text \ " :\ " \ " }]}] " )
20+ content Json @default (" null " )
2121 publishDate DateTime ?
2222 author Author ? @relation (" Post_author " , fields : [authorId ] , references : [id ] )
2323 authorId String ? @map (" author " )
@@ -30,5 +30,5 @@ model Author {
3030 name String @default (" " )
3131 email String @unique @default (" " )
3232 posts Post [] @relation (" Post_author " )
33- bio String @default (" [{ \ " type \ " :\ " paragraph \ " , \ " children \ " : [{ \ " text \ " :\ " \ " }]}] " )
33+ bio Json @default (" null " )
3434}
Original file line number Diff line number Diff line change @@ -15,6 +15,6 @@ generator client {
1515model User {
1616 id String @id @default (cuid () )
1717 name String @default (" " )
18- about String @default (" [{ \ " type \ " :\ " paragraph \ " , \ " children \ " : [{ \ " text \ " :\ " \ " }]}] " )
18+ about Json @default (" null " )
1919 createdAt DateTime ? @default (now () )
2020}
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ model Post {
2323 id String @id @default (cuid () )
2424 title String @default (" " )
2525 slug String @unique @default (" " )
26- content String @default (" [{ \ " type \ " :\ " paragraph \ " , \ " children \ " : [{ \ " text \ " :\ " \ " }]}] " )
26+ content Json @default (" null " )
2727 publishDate DateTime ? @default (now () )
2828 author User ? @relation (" Post_author " , fields : [authorId ] , references : [id ] )
2929 authorId String ? @map (" author " )
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ model Post {
1919 categoryId String ? @map (" category " )
2020 tags Tag [] @relation (" Post_tags " )
2121 related Post [] @relation (" Post_related " )
22- recommendations String @default (" [] " )
23- bundles String @default (" [] " )
22+ recommendations Json @default (" null " )
23+ bundles Json @default (" null " )
2424 from_Post_related Post [] @relation (" Post_related " )
2525
2626 @@index ([categoryId ] )
Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ generator client {
1313}
1414
1515model Homepage {
16- id Int @id
17- metadata String @default (" { \ " featuredPosts \ " : []} " )
16+ id Int @id
17+ metadata Json @default (" null " )
1818}
1919
2020model Post {
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ model Author {
2424model Post {
2525 id String @id @default (cuid () )
2626 title String @default (" " )
27- content String @default (" [{ \ " type \ " :\ " paragraph \ " , \ " children \ " : [{ \ " text \ " :\ " \ " }]}] " )
27+ content Json @default (" null " )
2828 author Author ? @relation (" Post_author " , fields : [authorId ] , references : [id ] )
2929 authorId String ? @map (" author " )
3030 tags Tag [] @relation (" Post_tags " )
Original file line number Diff line number Diff line change @@ -115,13 +115,16 @@ export function document<ListTypeInfo extends BaseListTypeInfo>({
115115 }
116116 }
117117
118+ const defaultValue = [ { type : 'paragraph' , children : [ { text : '' } ] } ]
118119 return fieldType ( {
119120 kind : 'scalar' ,
120121 scalar : 'Json' ,
121122 mode : 'required' ,
122123 default : {
123124 kind : 'literal' ,
124- value : JSON . stringify ( [ { type : 'paragraph' , children : [ { text : '' } ] } ] ) ,
125+ // TODO: waiting on https://github.com/prisma/prisma/issues/26571
126+ // input.create manages defaultValues anyway
127+ value : JSON . stringify ( ( meta . provider === 'sqlite' ? null : defaultValue ) ?? null ) ,
125128 } ,
126129 map : config . db ?. map ,
127130 extendPrismaSchema : config . db ?. extendPrismaSchema ,
@@ -133,7 +136,7 @@ export function document<ListTypeInfo extends BaseListTypeInfo>({
133136 arg : g . arg ( { type : g . JSON } ) ,
134137 resolve ( val ) {
135138 if ( val === undefined ) {
136- val = [ { type : 'paragraph' , children : [ { text : '' } ] } ]
139+ val = defaultValue
137140 }
138141 return inputResolver ( val )
139142 } ,
Original file line number Diff line number Diff line change @@ -16,9 +16,9 @@ model Thing {
1616 id String @id @default (cuid () )
1717 text String @default (" " )
1818 timestamp DateTime ?
19- structure Json @default (" null " )
20- structureNested Json @default (" null " )
21- structureRelationships Json @default (" null " )
19+ structure Json @default (" { \ " integer \ " :0 , \ " array \ " : []} " )
20+ structureNested Json @default (" [] " )
21+ structureRelationships Json @default (" [] " )
2222 checkbox Boolean @default (false )
2323 password String ?
2424 toOneRelationship User ? @relation (" Thing_toOneRelationship " , fields : [toOneRelationshipId ] , references : [id ] )
@@ -34,7 +34,7 @@ model Thing {
3434 selectOnSide String ?
3535 selectOnSideItemViewOnly String ?
3636 selectSegmentedControl String ?
37- multiselect Json @default (" null " )
37+ multiselect Json @default (" [] " )
3838 json Json ?
3939 integer Int ?
4040 decimal Decimal ? @postgresql.Decimal (32 , 8 )
You can’t perform that action at this time.
0 commit comments