Skip to content

Commit 74b0106

Browse files
committed
Docs update
1 parent 89dd825 commit 74b0106

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/linking_collections.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,40 @@ Posts.addLinks({
8080
You created the link, and now you can use the query illustrated above.
8181
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.
8282

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+
83117
## Inversed links
84118

85119
Because we linked `Posts` with `Meteor.users` it means that we can also get all `posts` of an user.

0 commit comments

Comments
 (0)