import Posts from '...';
import Categories from '...';
Posts.addLinks({
'categories': {
type: 'many',
collection: Categories,
field: 'categoryIds',
}
})
If there is a post in the db like
{ _id: 'postId', categoryIds: undefined } or
{ _id: 'postId', categoryIds: null } or
{ _id: 'postId', categoryIds: [] }
then
Posts.createQuery({ _id: 1, categories: { _id: 1 }}).fetch() would return [{ _id: 'postId' }] instead of [{ _id: 'postId', categories: [] }].
Issue example
If there is a post in the db like
{ _id: 'postId', categoryIds: undefined }
or{ _id: 'postId', categoryIds: null }
or{ _id: 'postId', categoryIds: [] }
thenPosts.createQuery({ _id: 1, categories: { _id: 1 }}).fetch()
would return[{ _id: 'postId' }]
instead of[{ _id: 'postId', categories: [] }]
.The same issue happens with inverse links