-
Notifications
You must be signed in to change notification settings - Fork 4
/
schema.ts
90 lines (84 loc) · 1.74 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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Database schema
/**
* Notes:
* - hierarchy consists of many collections, but shallow depth in each collection. This works nicely with subscribing
* listeners in useEffect. Also if collections are combined, single document updates may become too frequent.
*/
// Firestore
const collection = {
playlists: [
{
roomId: {
createdAt: 'timestamp',
url: 'https://youtube.com',
},
},
],
rooms: [
{
roomId: {
createdAt: 'timestamp',
ownerId: 'userId',
requests: [
{
createdAt: 'timestamp',
data: '01:25:44', // Contents of data depend on type of request
type: 'updateState',
senderId: 'userId',
},
],
},
},
],
states: [
{
roomId: {
time: 'timestamp',
isPlaying: true,
},
},
],
users: [
{
userId: {
name: 'Anonymous',
},
},
],
};
// Realtime Database - needed for tracking user presence
const turtle = {
// Needed for database triggers updating Firestore
available: {
roomId: {
createdAt: '2020-08-12T00:13:16.273Z',
},
},
// Keep chats in Realtime DB could potentially lower cost
chats: {
roomId: {
messageId: {
content: 'Message content',
senderId: 'userId',
createdAt: 'timestamp',
},
},
},
// Keeping track of which users are present in a room
rooms: {
roomId: {
userId: {
name: 'Username',
},
userCount: 0,
},
},
};
// TODO: Put in firebase.json
// "functions": {
// "predeploy": [
// "npm --prefix \"$RESOURCE_DIR\" run lint",
// "npm --prefix \"$RESOURCE_DIR\" run build"
// ],
// "source": "functions"
// },