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

Added projection aggregation operator #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Added projection aggregation operator #9

wants to merge 3 commits into from

Conversation

zacharynevin
Copy link

Select fields from the joining table using the projection field. Use it like a normal projection:

join({
   joinCollection: collection,
   leftKeys: [],
   rightKeys: [],
   newKey: '',
   projection: { 'column1: 1, 'column2': 0 }
})

This pull request simply just allows you to specify the fields needed for the joining collection. I couldn't get the nested join to work because I didn't have the array indices on hand needed to put the `rightRecord` at the correct index.

Use it like a normal projection:
````
join({
  joinCollection: collection,
  leftKeys: ['keys'],
  rightKeys: ['keys'],
  newKey: 'newKey',
  projection: { 'column1': 1, 'column2': 0 }
})
````
From what I could see there wasn't any information I could use that would give me the array index of a particular `rightRecord`, if the join involved an array. Instead I just wrote a small function called `correlate()` that correlates a `rightRecord` with its array position based on the `leftKeys` and `rightKeys`.

This works now for joins involving array data.
@zacharynevin
Copy link
Author

I just added a working method for nested joins as well.

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

Successfully merging this pull request may close these issues.

1 participant