Skip to content

How can I create a relation between different Schemas? #157

Answered by pkosiec
SelfDevTV asked this question in Q&A
Discussion options

You must be logged in to vote

Oh, right - sorry, my bad. In the examples directory there are no relations indeed. I thought you've just copied it from the repo, but you actually modified it. And you did it right - this is how the relation should look like, if you want to do it by document references.

So, it should look like this:

Posts:

const posts = [
  {
    id: getObjectId('post1'),
    title: 'Lorem ipsum',
    description: 'Sample Post 1 description',
    tags: ['sample', 'tags'],
    author: {
      name: 'Author',
      email: '[email protected]',
    },
    categories: [getObjectId("sample"), getObjectId("random")],
    comments: [],
    creationDate: new Date(),
  }
]

module.exports = posts;

Categories:

module.

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by pkosiec
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #157 on March 21, 2021 18:45.