Sparse indexing on username field to prevent duplicate null username error

This commit is contained in:
Sahat Yalkabov
2013-12-06 02:03:27 -05:00
parent 62a87a8542
commit bc2fa13d22

View File

@ -4,7 +4,7 @@ var mongoose = require('mongoose'),
var userSchema = new mongoose.Schema({
// Local authentication
username: { type: String, index: true, unique: true },
username: { type: String, unique: true, sparse: true },
password: String,
// OAuth 2.0 authentication