How can I get data from mongo and use data in meteor?


#1

Hi there~
I made two collections ‘users’ and 'posts’
in posts existing collections of data with the name “regId”, which is taken from _id collections ‘users’ as reference
this is JSON in mongo

‘posts’
{
"_id" : ObjectId(“57e67f0ad94b51ba8fdee839”),
“title” : “How to mongoimport and not use ObjectId in the _id fields”,
“contents” : “good”,
“regId” : DBRef(“users”, ObjectId(“57e7bce77c705856d323263b”)),
}

‘users’
{
"_id" : ObjectId(“57e7bce77c705856d323263b”),
“username” : “Josh”,
“email” : "bhw0506@gmail.com",
“password” : “Qus900506”,
“profile” : {
“username” : “Josh”,
“from” : “kakao”,
“friends” : [
DBRef(“users”, ObjectId(“57e7bce77c705856d323263b”))
],
“groups” : [

    ], 
    "company" : "Google", 
    "department" : "development"
}

}
and I brought it up like this in meteor

Template.Feed.helpers Feeds: ->
  return posts.find()

and I use this one on template
{{regId.username}}

of course it was wrong :frowning:
I want to get the name of data, how to bring it up?
plz help me~


#2

Please consider wrapping your code samples in backticks (on newlines) to help with formatting. For example:

```
Your code here
```

That being said, check out this related forum post:

I would recommend staying away from DBRef’s. Check out that post for alternatives, or dive directly into the Guide’s Publishing relational data and/or Associations between collections sections.