File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,40 @@ Posts.addLinks({
80
80
You created the link, and now you can use the query illustrated above.
81
81
We decided to choose ` author ` as a name for our link and ` authorId ` the field to store it in, but it's up to you to decide this.
82
82
83
+ ## Nested links
84
+
85
+ Nested links are also supported:
86
+
87
+ ``` js
88
+ // file: /imports/db/posts/links.js
89
+ import Posts from ' ...' ;
90
+
91
+ Posts .addLinks ({
92
+ ' authorObject.authorId' : {
93
+ type: ' one' ,
94
+ collection: Meteor .users ,
95
+ field: ' authorObject.authorId' ,
96
+ },
97
+ })
98
+ ```
99
+
100
+ In this example we're assuming that ` authorObject ` is a nested document inside ` Posts ` collection, and we want to link it to ` Meteor.users ` .
101
+
102
+ Nested arrays are also supported, e.g.:
103
+
104
+ ``` js
105
+ // file: /imports/db/posts/links.js
106
+ import Posts from ' ...' ;
107
+
108
+ Posts .addLinks ({
109
+ ' authorsArray.authorId' : {
110
+ type: ' one' ,
111
+ collection: Meteor .users ,
112
+ field: ' authorsArray.authorId' ,
113
+ },
114
+ })
115
+ ```
116
+
83
117
## Inversed links
84
118
85
119
Because we linked ` Posts ` with ` Meteor.users ` it means that we can also get all ` posts ` of an user.
You can’t perform that action at this time.
0 commit comments