diff --git a/ws1/synergy/models/admin.js b/ws1/synergy/models/admin.js index 8153935..a2b852e 100644 --- a/ws1/synergy/models/admin.js +++ b/ws1/synergy/models/admin.js @@ -12,9 +12,11 @@ var adminSchema = new mongoose.Schema({ }); adminSchema.statics.deleteUser = function(userid){ - User.remove({_id : userid}, function(err){ - if(err) + User.findOneAndUpdate({_id : userid}, {$set: {deleted: true}}, function(err, update){ + if(err){ throw(err); + } + update.save(); }); } adminSchema.statics.deleteUsers = function(users, userids, deletes, callback){ @@ -22,7 +24,6 @@ adminSchema.statics.deleteUsers = function(users, userids, deletes, callback){ var j = 0; for(var i = 0; i < users.length; i++){ if(deletes[i] == 1){ - console.log(userids[i]); adminSchema.statics.deleteUser(userids[i]); deleted[j] = i; j++; diff --git a/ws1/synergy/models/user.js b/ws1/synergy/models/user.js index 4a343b7..867bbaf 100755 --- a/ws1/synergy/models/user.js +++ b/ws1/synergy/models/user.js @@ -49,7 +49,7 @@ var userSchema = new mongoose.Schema({ }); userSchema.statics.list = function (callback) { - this.find(function (err, users) { + this.find({deleted : false}, function (err, users) { if (err) { return (err, null); } else {