forked from keystonejs/keystone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.ts
29 lines (28 loc) · 855 Bytes
/
schema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { createSchema, list } from '@keystone-next/keystone';
import { select, relationship, text, timestamp } from '@keystone-next/keystone/fields';
import { stars } from './stars-field';
export const lists = createSchema({
Post: list({
fields: {
title: text({ isRequired: true }),
status: select({
dataType: 'enum',
options: [
{ label: 'Draft', value: 'draft' },
{ label: 'Published', value: 'published' },
],
}),
content: text(),
rating: stars(),
publishDate: timestamp(),
author: relationship({ ref: 'Author.posts', many: false }),
},
}),
Author: list({
fields: {
name: text({ isRequired: true }),
email: text({ isRequired: true, isIndexed: 'unique' }),
posts: relationship({ ref: 'Post.author', many: true }),
},
}),
});