I see several issues here:
Most importantly, the closure as a duplicate of Mongo db conditional query was an abuse of the dupehammer. Your question was not a duplicate of that question. In normal circumstances we might chalk this up to the user not having read your question properly (mistakes happen sometimes)... but in this case, we can see from his engagement with the question in chat that the user knew perfectly well what you were asking; it seems to me that he was clearly aware that his chosen dupe target was not a real duplicate.
For better or worse, the site gives gold tag badge holders the power to unilaterally close duplicates and only duplicates. The dupehammer is not supposed to be a tool to let gold badge holders close any question they don't like for any reason at all by marking it as a duplicate of some arbitrary vaguely-related question. Even if your question deserved to be closed (which it doesn't), the user should've cast a normal close vote and hoped that the question would accrue the 5 votes needed for closure, just like the rest of us have to do when we try to close questions.
Secondly, the user's technical reasoning seems pretty dubious. It's been ages since I worked with Mongo and I've thankfully forgotten almost everything about it, but I'd be amazed if it wasn't possible to construct a query that, at least for practical purposes, always returns no results, even if it's something hacky like checking for the existence of a key called keyIMadeUpWhoseWholePurposeIsToNotExistOnAnyDocument
. And though your use case is valid (it's just a fact of life that sometimes you've got to slot some functionality into a system that demands you frame your logic as a database query, or a regex, or something along those lines, even when that's not the most natural way of doing things), the user doesn't seem to grasp that or be able to imagine why what you're doing might make sense.
Thirdly, the user has failed to provide any rationale for his claim that no solution is possible. While it's perfectly reasonable to answer that what a question is asking for is impossible, you should show your reasoning when doing so, or else there's no reason for anyone to believe you.
And finally, the user was frankly a bit of an ass to you, when you'd done nothing to deserve it. The user's "big gold badge" in no way guarantees that he's right or that he knows more than you, and if he is right then he should be able to articulate the reasoning for why rather than demanding that you trust his authority. The whole final comment to you was nothing but an arrogant refusal to back up his claims followed by what I'd at least call a clear expression of disrespect towards you, even if I wouldn't quite go so far as to call it a "direct insult" as you do in your Meta post here.
I'm sorry you got treated this way. This kind of condescension is never pleasant to start with, but I at least have some sympathy for it when it's coming from someone who is right on the merits of their arguments. Seeing you receive it, on the other hand, over a question that really was completely legitimate, from a user who seems to have just failed to grasp the motivation behind the question, is infuriating. In light of that, I admire the measured tone of your Meta post here.
FWIW, although I don't think the user's messages in chat quite rise to the point of deserving a word from the moderators, I think the abuse of the dupehammer does, and I'm about to raise a flag accordingly.