-
Notifications
You must be signed in to change notification settings - Fork 5
/
schema.js
46 lines (42 loc) · 1.22 KB
/
schema.js
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
41
42
43
44
45
46
/** @type {import('@nokkio/schema').Config} */
module.exports = function ({ defineModel, types }) {
const User = defineModel('User', {
sub: types.string().unique(),
email: types.string().filterable(),
name: types.string(),
picture: types.string(),
isAdmin: types.bool(false),
isBanned: types.bool(false),
});
const Story = defineModel('Story', {
prompt: types.text(),
state: types
.string('created')
.oneOf([
'created',
'generating_story',
'generating_media',
'ready',
'failed',
])
.filterable(),
imagePrompt: types.text(null),
title: types.string(null),
summary: types.text(null),
text: types.text(null),
duration: types.number(null),
image: types.image(null),
audio: types.text(null),
attempt: types.number(1),
completedAt: types.datetime(null),
isPublic: types.bool(false),
isDailyStory: types.bool(false),
});
// Enforce model event ordering only at the record
// level to reduce latency / contention.
Story.orderEventsByRecord();
Story.belongsTo(Story, { optional: true, name: 'parentStory' });
User.hasMany(Story);
User.actAsAuth({ type: 'custom' });
return { Story, User };
};