We’re trying to determine the subtype of BinData objects. It can be done with the .type field when you pass the BinData object into a JS function, but from what I can tell it isn’t possible to get the subtype from the BinData BSON object, with the .type field or any other method. For example:

db.coll.aggregate([
    {
        "$project": {
            "uuid_type": {  "$type": UUID() },
            "js_uuid_subtype": {
                "$function": {
                    "body": "function(uuid) { return uuid.type; }",
                    "args": [  UUID() ],
                    "lang": "js"
                }
            },
            "bson_uuid_subtype": UUID().type
        }
    }
])
[
  {
    _id: ObjectId('67dc5784677dddbefba00aa2'),
    uuid_type: 'binData',
    js_uuid_subtype: 4,
    bson_uuid_subtype: null
  }
]

If you could provide a way to determine the subtype of a BinData BSON object without passing it into a JS function, or confirm that it isn’t possible, that would be great.