diff --git a/server/initializers/checker.js b/server/initializers/checker.js index 3831efb8d..871d3cac2 100644 --- a/server/initializers/checker.js +++ b/server/initializers/checker.js @@ -39,10 +39,10 @@ function clientsExist (callback) { } function usersExist (callback) { - User.list(function (err, users) { + User.count(function (err, totalUsers) { if (err) return callback(err) - return callback(null, users.length !== 0) + return callback(null, totalUsers !== 0) }) } diff --git a/server/models/user.js b/server/models/user.js index 351ffef86..d289da19a 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -19,6 +19,7 @@ UserSchema.methods = { } UserSchema.statics = { + count: count, getByUsernameAndPassword: getByUsernameAndPassword, list: list, loadById: loadById, @@ -29,6 +30,10 @@ mongoose.model('User', UserSchema) // --------------------------------------------------------------------------- +function count (callback) { + return this.count(callback) +} + function getByUsernameAndPassword (username, password) { return this.findOne({ username: username, password: password }) }