docs
docs copied to clipboard
Mention that $type can't inspect array elements
Hey @dandv -- didn't forget about this pull. It's because I want to kind of finesse the wording since we can use $arrayElemAt to pass in an array element to the $type. So, definitely get the gist of your pull, just thinking things through.
MongoDB Enterprise > db.foo.find()
{ "_id" : ObjectId("5d72d8df9eecd5d9513aa02f"), "x" : [ "1", "2" ] }
MongoDB Enterprise > db.foo.aggregate( [ { $project: { myType: { $type: {$arrayElemAt: [ "$x", 0 ] } } } } ] )
{ "_id" : ObjectId("5d72d8df9eecd5d9513aa02f"), "myType" : "string" }