public
Created

remove specialty

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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})
}
}
},

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.