Created
January 16, 2013 17:57
-
-
Save astrotars/4549233 to your computer and use it in GitHub Desktop.
extract id from clients array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clientSchema.pre('remove', function(next) { | |
// clean up dependencies | |
Sweepstakes.remove({client_id: this._id}).exec(); | |
Submission.remove({client_id: this._id}).exec(); | |
// remove client id from users | |
User.update({clients: {$in: [this._id]}}, {$pull: {clients: this._id}}, function(err, numAffected) { | |
if (err) | |
console.log(err); | |
console.log('NUMBER OF ROWS AFFECTED: ', numAffected); | |
next(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment