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

using valueAggregator in fromArray #70

Open
dehbini-git opened this issue Oct 14, 2021 · 2 comments
Open

using valueAggregator in fromArray #70

dehbini-git opened this issue Oct 14, 2021 · 2 comments

Comments

@dehbini-git
Copy link

dehbini-git commented Oct 14, 2021

Hello,
As valueAggregator returns an array, it would be nice if I could pass the array to the parameter "in" of fromArray.
This is my issue:
We have 3 collections : stores, users, events
stores:
{ "_id": ObjectId('store') }

users :
{ "_id": ObjectId('user'), "firstName":..., "lastName":..., "storeId": ObjectId('store') }

events:
{ "_id": ObjectId('event')], "participants": [ { "id": ObjectId('user') } ], "storeId": ObjectId('store') }
What I want?
I want participants in event will be populated with the random numbers of users which belong to the same store.
If we can mix fromArray with valueAggregator, I think it will solve the issue.

@feliixx
Copy link
Owner

feliixx commented Oct 15, 2021

Hi @dehbini-git ,

The ref generator may solve your issue, you can use it like in this example:

https://mongoplayground.net/p/-_ITiQ2Y-vU

would this work for you ?

@dehbini-git
Copy link
Author

dehbini-git commented Oct 16, 2021

Hi @feliixx ,
Unfortunately no. I want all participants in events collections have same store Id. But with ref participants are randomly will be from users collection and each user can have different storeId. What I want is all participants will ref to users but belongs to the same store that I think it is possible with Aggregator.

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

2 participants