Database

[{"_id":"1","blocks":[{"port":[{"portType":{"function":"input"}}]}]}]

Query

db.collection.aggregate([{"$unwind":"$blocks"},{"$unwind":"$blocks.port"},{"$match":{"blocks.port.portType.function":"input"}}])

Result