Hi Everyone,
In our Go codebase, we’re building dynamic projection maps for queries. Instead of using map[string]int{"name": 1}, we’re considering using map[string]bool{"name": true} for cleaner and more expressive code.
We understand that MongoDB currently treats true and 1 equivalently in projections. However, we’d like to confirm:
- Is it officially supported and safe to use
true/falsevalues in projection documents long-term? - Is there any risk that future MongoDB versions may stop treating
trueand1the same way? - Does the MongoDB engine or Go driver perform any significant conversion overhead when using
boolvalues in projection?
Thanks in advance — we just want to make the cleanest and safest long-term choice.