Two separate paths to the same collection
Mhal007 opened this issue · comments
Hello,
I am trying to extract data from a collection with two different paths - some fields by connecting collections: A -> B -> C -> D and other fields with a path A -> C.
How can I achieve that?
It's not possible at the moment, due to connection mechanism: it can handle trees, not even DAGs. Although, I have an idea for the API. When defining relations
, collection names will be either a real (database) names or some kind of aliases. Then all you'll need to do will be providing a mapping from aliases into real names.
Example:
const pipeline = build({
projection: {
x: 'A1.x',
y: 'A2.y'
},
// Not present <=> real name.
// This key name is just an idea.
real: {A1: 'A', A2: 'A'},
relations: [
{
from: 'S',
to: 'A1',
foreign: '_id',
local: '_id'
},
{
from: 'S',
to: 'A2',
foreign: '_id',
local: '_id'
}
],
start: 'S'
});
What do you think?
Seems like a great idea! Can't wait until it's ready :)