Meteor.js one to many


#1

Hello, I need to assign avatar to a user.
Now I’m using ID, really not the best solution though.
Could anyone share code with the simpliest way to do it with ORM?


#2

Typically what you would do to accomplish a one to many relationship in Mongo is you’d add the foreign key of the “one” document to whatever “many” documents you want to assign it to. For instance, let’s say I have a blog and I want to know who created a particular post. I could simply add a userId property to the new post document.

post = {
  title: 'Meteor.js one to many',
  body: 'Super long post',
  userId: Meteor.userId()
}