Created
June 8, 2022 15:00
-
-
Save socialwell-demos/84fee9c430c3741d5364044cab971cf7 to your computer and use it in GitHub Desktop.
Keystone List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { list } from '@keystone-6/core'; | |
import { select, relationship, text, timestamp } from '@keystone-6/core/fields'; | |
export const lists = { | |
Post: list({ | |
fields: { | |
title: text({ validation: { isRequired: true } }), | |
status: select({ | |
type: 'enum', | |
options: [ | |
{ label: 'Draft', value: 'draft' }, | |
{ label: 'Published', value: 'published' }, | |
], | |
}), | |
content: text(), | |
publishDate: timestamp(), | |
author: relationship({ ref: 'Author.posts', many: false }), | |
}, | |
}), | |
Author: list({ | |
fields: { | |
name: text({ validation: { isRequired: true } }), | |
email: text({ isIndexed: 'unique', validation: { isRequired: true } }), | |
posts: relationship({ ref: 'Post.author', many: true }), | |
}, | |
}), | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment