mongoose sparse index

JavaScript
var User = new Schema({
    name: { type: String, sparse: true }
})
Source

Also in JavaScript: