Mongo db lookup equivalent filter in metabase

Hi, i have connected my mongodb in metabase for getting better report view… for this i have to join table like $lookup in mongodb… when i search for this i got a feature like setting source as previously saved question in metabase… but unfortunately saved question not shown in ask question section… why? can you please help me to get data by applying condition in more than one table?

Hi @Anusree
You cannot use MongoDB queries as Saved Question source:

1 Like

Then how can i get result by applying condition in more than one table?

@Anusree I don’t understand your question. If you need to do something that is more advanced than what the UI can do, then use Native query. You can get help on or similar forums on how to write general MongoDB queries, since it’s not specific to Metabase.

                       await User.aggregate([
                            {$match: {user_id: 1, is_open: true}},
                                  from: "trainingrequests",
                                  localField: "user_id",
                                  foreignField: "training_id",
                                  as: "trainingrequests"
                           {$match: {$and: [
                               {"trainingrequests.is_live": true},

this my code in mongoose… is it possible to get equivalent result by using Native query?

@Anusree Except for the await function, then yes, that’s just a query you can run.

ok… THanks @flamber

“$match”: {“agency_id”: “3”}
}, { “$lookup”: {
“from”: “usersduplicates”,
“localField”: “agency_id”,
“foreignField”: “user_id”,
“as”: “usersduplicates”

first $match i working properly… but bellow $lookup code part does not make any change in the result… can you please hep me to solve this issue?

@Anusree I guess you’re seeing this limitation: - upvote by clicking :+1: on the first post

OK… so you mean to say that filter by foreign key model attribute Metabase show error… then how can i apply condition for more than on collections?

@Anusree I don’t use Mongo. If you’re hitting a limitation in Metabase, then there’s not much you can do besides using Stitch or similar services that puts your data into Postgres, which works better in Metabase.