Database
[{_id:1,name:"joe",snapshot:null,age:30},{_id:2,name:"joe",snapshot:"snapshot1",age:30},{_id:3,name:"joe",snapshot:"snapshot15",age:30},{_id:4,name:"joe",snapshot:"snapshot23",age:30}]
Query
db.collection.aggregate([{"$group":{"_id":"$name","name":{"$first":"$name"},"age":{"$first":"$age"},"snapcount":{"$sum":{"$cond":[{"$eq":[{"$type":"$snapshot"},"string"]},1,0]}}}},{"$unset":"_id"}])