From my understanding of the problem, the issue is likely due to Metabase using a $function operator in aggregation queries, which requires server-side JavaScript execution, something DigitalOcean’s MongoDB doesn’t allow.
Since $function is the problem, we need to rewrite the query to remove JavaScript execution. You have a few options:
Replace $function with a native MongoDB aggregation operator
Use a client-side transformation
Could you share the specific MongoDB query that fails? That would help in converting it to a JavaScript-free alternative
We’re trying to determine the subtype of BinData objects. It can be done with the .type field when you pass the BinData object into a JS function, but from what I can tell it isn’t possible to get the subtype from the BinData BSON object, with the .type field or any other method. For example:
If you could provide a way to determine the subtype of a BinData BSON object without passing it into a JS function, or confirm that it isn’t possible, that would be great.
The query is in the link, but I can paste it here for posterity. I’ve preserved the surrounding clojure which defines multiple queries for context. The query with the JS is assigned to the initial-items variable. The type-alias inside the $map which uses the ternary to return ‘uuid’ or type is the JS that would be nice to replace. I’m neither a clojure developer nor a mongodb expert, so bear with any misinterpretations I may have made.