Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join user collection #19

Open
karambita opened this issue Jun 9, 2015 · 2 comments
Open

Join user collection #19

karambita opened this issue Jun 9, 2015 · 2 comments

Comments

@karambita
Copy link

Hi,
Let's say we have companies collection and want to join users collection where the profile information is stored.
Would it be possible to define joins with the users collection in the json file?

Great work btw.
Thanks

@perak
Copy link
Owner

perak commented Jun 9, 2015

Hi,

I didn't try that, maybe it's possible... being super busy at the moment, can you try join and let me know what happens?

Maybe you can do something like:

{
  "name": "companies",
  "fields": [
    {
      "name": "company_name",
      "title": "Company name"
    },
    {
      "name": "userId",
      "join_collection": "users",
      "join_container": "user",
      "join_fields": ["profile"]
    }
  ]
}

@ljack
Copy link

ljack commented Apr 9, 2016

Ah, users join didn't work for me either but it's doable using transform option:

queries/todos
{
    "transform": "function(doc) {doc.sharedToDoc={}; Meteor.users.find({ _id: doc.ownerId }).map(function(user) { doc.owner = user });  Meteor.users.find({ _id: {'$in': doc.sharedTo}}).map( function(user) {doc.sharedToDoc[user._id]=user; } ); console.log('doc=',doc);return doc;}",
    "sort": [
        "name"
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants