How to use query or $lookup in the sibling DB

Hello Everyone,

I need to query the sibling DB.

This is the closest thing attached to this: https://www.mongodb.com/docs/atlas/data-federation/supported-unsupported/pipeline/lookup-stage/

but not sure how we can use it with Meteor.

Although I can use it from the MongoDB shell but not in the actual code. Since we do not have a DB object (Please let me know if there is any way we can have DB Object), So we can’t have the method accessible in the code

I believe $lookup is part of the Aggregation API which you can learn about here: MongoDB Courses and Trainings | MongoDB University

Also in Atlas and MongoDB Compass you have an Aggregation tool to test your query and results.

This is how Meteor Grapher implements an aggregate “hook” for your Meteor Collection:

import { Promise } from 'meteor/promise';

Mongo.Collection.prototype.aggregate = function(pipelines, options = {}) {
    const coll = this.rawCollection();

    let result = Meteor.wrapAsync(coll.aggregate, coll)(pipelines, options);

    // We need to check If it's an AggregationCursor
    // The reason we do this was because of the upgrade to 1.7 which involved a mongodb driver update
    if (Array.isArray(result)) {
        return result;
    } else {
        return Promise.await(result.toArray());
    }
};