-
Notifications
You must be signed in to change notification settings - Fork 0
/
api-proposal-v2.js
56 lines (50 loc) · 1.22 KB
/
api-proposal-v2.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
47
48
49
50
51
52
53
54
55
56
Guest.attachDenormalizedSchema({
name: { type: String },
})
Comments.attachDenormalizedSchema({
comment: { type: String },
// 1 comment has 1 post
postId: {
type: String,
optional: false,
denormalize: {
relation: Denormalize.HAS_ONE,
relatedCollection: Posts,
pickProperties: ['post'],
},
},
// postCache will be created (and synced with Posts collection)
// guest
guestId: {
type: String,
optional: false,
denormalize: {
relation: Denormalize.HAS_ONE,
relatedCollection: Guest,
pickProperties: ['name'],
},
},
})
Posts.attachDenormalizedSchema({
post: { type: String },
// 1 comment has 1 post
commentIds: {
type: [String],
optional: true,
denormalize: {
relation: Denormalize.HAS_MANY,
relatedCollection: Comments,
pickProperties: ['comment'],
},
},
// commentCache will be created (and synced with Comments collection)
})
/**
* Scenario:
*
* Guest writes a comment for a post.
* - the comment stores the guest (and within the guestCache his name)
* - the post stores the comment (and within the commentCache.guestCache his name)
* - what if now guest updates his name: Will Post be updated?
*
*/