From bc2fa13d22d991e8f535fa909a42b72c8ee27261 Mon Sep 17 00:00:00 2001 From: Sahat Yalkabov Date: Fri, 6 Dec 2013 02:03:27 -0500 Subject: [PATCH] Sparse indexing on username field to prevent duplicate null username error --- models/User.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/User.js b/models/User.js index 8733d9b84d..2d862c3271 100644 --- a/models/User.js +++ b/models/User.js @@ -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