Skip to content

Instantly share code, notes, and snippets.

@shinecita
Created October 23, 2012 20:06
Show Gist options
  • Save shinecita/3941190 to your computer and use it in GitHub Desktop.
Save shinecita/3941190 to your computer and use it in GitHub Desktop.
adding a User
Model.addUser = function(model, user, done) {
User.save({_id: toObjectId(model), $addToSet: {organizations: toObjectId(model)}}, function(err, user) {
// user.organizations || (user.organizations = []);
// user.organizations.push(toObjectId(model));
done(null, user);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment