-
Notifications
You must be signed in to change notification settings - Fork 15
/
schema.ts
38 lines (36 loc) · 1.4 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
// Code copied (with some modifications) from the Keystone 6 "with-auth" example
// See.. https://github.com/keystonejs/keystone/tree/master/examples/with-auth
import { list } from '@keystone-6/core';
import { checkbox, password, relationship, text, timestamp, select } from '@keystone-6/core/fields';
export const lists = {
Task: list({
fields: {
label: text({ isRequired: true }),
priority: select({
dataType: '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({
fields: {
name: text({ 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 both isRequired and isUnique
email: text({ isRequired: true, isUnique: true, isIndexed: 'unique' }),
// 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 isRequired flag.
password: password({ isRequired: true }),
tasks: relationship({ ref: 'Task.assignedTo', many: true }),
},
}),
};