I have an array of data which describes entity relationships. My code:
services
.tree
.collection
.find()
.$
.pipe(
switchMap(from),
groupBy((value) => value.get('parent_id')),
mergeScan((memo, group$) => {
const key = group$.key;
return group$.pipe(
map((value) => {
if(!(key in memo)) {
memo[key] = [];
}
memo[key].push(value);
return memo;
})
)
}, {}),
)
.subscribe((data) => console.log('data', data));
But instead of one log a have many. How can I merge all it in one pipeline to have a single data at the end?