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

Joins into the array #231

Open
dspangenberg opened this issue Jul 27, 2017 · 0 comments
Open

Joins into the array #231

dspangenberg opened this issue Jul 27, 2017 · 0 comments
Labels

Comments

@dspangenberg
Copy link

I have a collection (contacts) with an array of email addresses. Every email has a category, which I will join directly to the similar item in the array. Is this possible?

Simplified contacts collection:

contacts = [
  {
    name: 'John Doe',
    emails: [
      {
        value: '[email protected]',
        category: 'abcdefg'
      },
      {
        value: '[email protected],
        category: 'hijklmn'
      }
    ]
  }
]

Simplified categories collection:

emailCategories = [
  {
    _id: 'abcdefg',
    name: 'Work'
  },
  {
    _id: 'hijklmn',
    name: 'Home'
  }
]

Wished result:

result = [
  {
    name: 'John Doe',
    emails: [
      {
        value: '[email protected]',
        category: {
          name: 'Work'
        }
      },
      {
        value: '[email protected],
        category: {
          name: 'Home'
        }
      }
    ]
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants