Skip to content

Commit

Permalink
changed how user is deleted. Now deleted flag for user is toggled to …
Browse files Browse the repository at this point in the history
…true.
  • Loading branch information
Roland Gee committed Apr 6, 2015
1 parent 74f437f commit ad3006b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions ws1/synergy/models/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ 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){
deleted = [];
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++;
Expand Down
2 changes: 1 addition & 1 deletion ws1/synergy/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ad3006b

Please sign in to comment.