A few additional questions:
- When you say that you are in the console, are you using the new MongoDB Shell (
mongosh)? This would be the case if you are using the shell embedded in Compass.
- Does the operation execute correctly (eg it finds the right results) and the main problem here is the fact that the displayed information (of
[Object]) is confusing and misleading?
Based on the information here, I suspect that problem is related to how the
mongosh utility prints information by default. There is an
inspectDepth setting that will begin truncating nested information once a certain depth is reached for overall readability purposes. In your situation, the addition of the
$or operator results in the field having additional levels of nesting.
What’s not immediately obvious is why the change in display is being applied to
deactivatedDate but not
isActive:true which appear to be at the same depth. If the value for both of those fields were a simple data type rather than an object then I would expect both values to be displayed. There are a few things that this could imply, but regardless I think the suggestions below may help.
First, please be sure that you are running the most recent version of
mongosh. With it, you can use the following command to check on the setting of the depth inspection:
You can modify the setting using the following command:
Documentation for the same can be found here.
Thanks for using MongoDB!