forked from keystonejs/keystone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.ts
40 lines (39 loc) · 1.49 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
import { list } from '@keystone-6/core';
import { allowAll } from '@keystone-6/core/access';
import { checkbox, password, relationship, text, timestamp } from '@keystone-6/core/fields';
import { select } from '@keystone-6/core/fields';
import type { Lists } from '.keystone/types';
export const lists: Lists = {
Task: list({
access: allowAll,
fields: {
label: text({ validation: { isRequired: true } }),
priority: select({
type: 'enum',
options: [
{ label: 'Low', value: 'low' },
{ label: 'Medium', value: 'medium' },
{ label: 'High', value: 'high' },
],
}),
isComplete: checkbox(),
assignedTo: relationship({ ref: 'Person.tasks', many: false }),
finishBy: timestamp(),
},
}),
Person: list({
access: allowAll,
fields: {
name: text({ validation: { isRequired: true } }),
// Added an email and password pair to be used with authentication
// The email address is going to be used as the identity field, so it's
// important that we set isRequired and isIndexed: 'unique'.
email: text({ isIndexed: 'unique', validation: { isRequired: true } }),
// The password field stores a hash of the supplied password, and
// we want to ensure that all people have a password set, so we use
// the validation.isRequired flag.
password: password({ validation: { isRequired: true } }),
tasks: relationship({ ref: 'Task.assignedTo', many: true }),
},
}),
};