'Foreign-keys is not supported by this driver' error in MongoDB

I have two mongodb collections ‘topics’ and ‘subjects’ with schema :
`topic :
{ _id: ObjectId,
name: String,
subject: ObjectId of subject to which it belongs
}

subject:
{ _id: ObjectId,
name: String
}
`

I have manually defined the foreign key for topic in data-model.
Now, I want to simply count the number of topics for every subject. But I facing this error while grouping my topics by subjects and the error is : “Foreign-keys is not supported by this driver”.

2 Likes

Hi,

Any news about this? I’m getting the same error :frowning:

“foreign-keys is not supported by this driver”

Unfortunately, foreign key relationships aren't supported by our MongoDB driver:

Is this still an issue. I am getting “mongo driver does not support foreign key” error and cannot filter my questions by name

@ChristineChetty Yes, the issue is still open. Upvote by clicking :+1: on the first post of the issue.

Oh no… Have you found a work around that you can recommend? I really just need to filter by a Company ID which is Foreign Key

@ChristineChetty I have no idea how MongoDB works, so I don’t know if you can create views similar to other SQL-based databases, but that would be the workaround.

This seems to indicate that joins are possible: https://github.com/metabase/metabase/issues/9095

I suppose one could join tables to create a view inside metabase and then filter that view

@ChristineChetty When you see an open issue, then it’s still not implemented/fixed, so no, MongoDB doesn’t support joins in Metabase yet.