Ok so something like this?
merchant = { _id: 'merchant1' }
user = { _id: 'user1', manages: { merchantId: 'merchant1' } };
venues = { _id: 'venue1', merchantId: 'merchant1' };
I don’t think you need to query any intermediary collection.
As I understand, you are just trying to get venues where venue.merchantId === user.manages.merchantId
Are you using flattenMode: 'auto'
? If not tell me, we’ll write a more complete answer
agent.customizeCollection('users', collection => {
collection.addOneToManyRelationship('userVenus', 'venue', {
originKey: 'merchantId',
originKeyTarget: 'manages@@@merchantId' // name of the flattened field, this should show on the autocompletion
});
});