-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstant.schema.ts
More file actions
66 lines (62 loc) · 1.96 KB
/
instant.schema.ts
File metadata and controls
66 lines (62 loc) · 1.96 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Docs: https://www.instantdb.com/docs/modeling-data
import { i } from "@instantdb/react";
const _schema = i.schema({
entities: {
$files: i.entity({
path: i.string().unique().indexed(),
url: i.string(),
}),
$users: i.entity({
email: i.string().unique().indexed().optional(),
}),
profiles: i.entity({
username: i.string().unique().indexed(),
supporter: i.boolean().optional(),
supporterSince: i.date().optional(),
supporterUntil: i.date().optional(),
stripeCustomerId: i.string().optional(),
stripeDetails: i.json().optional(),
createdAt: i.date(),
}),
blocks: i.entity({
x: i.number().optional(),
y: i.number().optional(),
z: i.number().optional(),
type: i.string(),
sessionId: i.string().optional().indexed(),
plantedAt: i.date().optional(),
}),
sessions: i.entity({
sessionId: i.string().optional().indexed(),
createdAt: i.number(),
timeInSeconds: i.number(),
timeRemaining: i.number().optional(),
paused: i.boolean().optional(),
completedAt: i.date().optional(),
rewardsClaimedAt: i.date().optional(),
cancelledAt: i.date().optional().indexed(),
type: i.string().optional().indexed(), // 'focus' or 'break'
}),
},
links: {
userProfile: {
forward: { on: 'profiles', has: 'one', label: 'user' },
reverse: { on: '$users', has: 'one', label: 'profile' }
},
userSessions: {
forward: { on: 'sessions', has: 'one', label: 'user' },
reverse: { on: '$users', has: 'many', label: 'sessions' }
},
userBlocks: {
forward: { on: 'blocks', has: 'one', label: 'user' },
reverse: { on: '$users', has: 'many', label: 'blocks' }
},
},
rooms: {},
});
// This helps Typescript display nicer intellisense
type _AppSchema = typeof _schema;
interface AppSchema extends _AppSchema {}
const schema: AppSchema = _schema;
export type { AppSchema };
export default schema;