Skip to content

Instantly share code, notes, and snippets.

@olawiberg
Created October 29, 2012 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olawiberg/3977137 to your computer and use it in GitHub Desktop.
Save olawiberg/3977137 to your computer and use it in GitHub Desktop.
remove specialty
removeSpecialty: function(options) {
var userId = options.userId;
var toRemove = options.specialty || {};
var topic = Topics.findOne({name:toRemove.name});
var user = Meteor.users.findOne(userId)
if(!user)
throw new Meteor.Error("User not found")
if(!topic)
throw new Meteor.Error("Topic not found")
var current = _.map(user.profile.specialties, function(obj){return obj._id})
if(_.isObject(topic)) {
if(_.contains(current,topic._id)) {
Meteor.users.remove({_id: topic._id})
}
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment