}
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)
})
}
}
UserSchema.statics = {
+ count: count,
getByUsernameAndPassword: getByUsernameAndPassword,
list: list,
loadById: loadById,
// ---------------------------------------------------------------------------
+function count (callback) {
+ return this.count(callback)
+}
+
function getByUsernameAndPassword (username, password) {
return this.findOne({ username: username, password: password })
}