In trying to figure out the optional lab, I started experimenting with $type
, and now I’m confused.
db.movies.aggregate([
{
$match: { writers: { $elemMatch: { $exists: true } } }
}
]).itcount()
results in an output of: 41491
If I change the $match
to:
db.movies.aggregate([
{
$match: { writers: { $type: "string" } }
}
]).itcount()
I get the exact same count.
writers
is supposed to be an array (of string, yes), but why doesn’t $type differentiate between those?