<commit_before>var mongoose = require('mongoose')
  , async = require('async')
  , User = require('./user')
  , Event = require('./event');

// Creates a new Mongoose Schema object
var Schema = mongoose.Schema;

// Collection to hold users
var TeamSchema = new Schema({
    name: { type: String, required: true, unique: true},
    description: { type: String },
    userIds: [{type: Schema.Types.ObjectId, ref: 'User'}],
  },{
    versionKey: false
  }
);

TeamSchema.pre('remove', function(next) {
  var team = this;

  async.parallel({
    user: function(done) {
      User.removeTeamFromUsers(team, done);
    },
    teams: function(done) {
      Event.removeTeamFromEvents(team, next);
    }
  },
  function(err, results) {
    next(err);
  });
});

var transform = function(team, ret, options) {
  ret.id = ret._id;
  delete ret._id;

  ret.users = ret.userIds;
  delete ret.userIds;
}

TeamSchema.set("toJSON", {
  transform: transform
});

// Creates the Model for the User Schema
var Team = mongoose.model('Team', TeamSchema);
exports.TeamModel = Team;

exports.getTeamById = function(id, callback) {
  Team.findById(id).populate('userIds').exec(callback);
}
<commit_msg>Bug Fix<commit_after>var mongoose = require('mongoose')
  , async = require('async')
  , User = require('./user')
  , Event = require('./event');

// Creates a new Mongoose Schema object
var Schema = mongoose.Schema;

// Collection to hold users
var TeamSchema = new Schema({
    name: { type: String, required: true, unique: true},
    description: { type: String },
    userIds: [{type: Schema.Types.ObjectId, ref: 'User'}],
  },{
    versionKey: false
  }
);

TeamSchema.pre('remove', function(next) {
  var team = this;

  async.parallel({
    user: function(done) {
      User.removeTeamFromUsers(team, done);
    },
    teams: function(done) {
      Event.removeTeamFromEvents(team, next);
    }
  },
  function(err, results) {
    next(err);
  });
});

var transform = function(team, ret, options) {
  ret.id = ret._id;
  delete ret._id;

  if (team.populated('userIds')) {
    ret.users = ret.userIds;
    delete ret.userIds;
  }
}

TeamSchema.set("toJSON", {
  transform: transform
});

// Creates the Model for the User Schema
var Team = mongoose.model('Team', TeamSchema);
exports.TeamModel = Team;

exports.getTeamById = function(id, callback) {
  Team.findById(id).populate('userIds').exec(callback);
}

{'fraction_non_alphanumeric': 0.1582463465553236, 'fraction_numerical': 0.0, 'mean_word_length': 3.6165703275529864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4842616', 'n_tokens_mistral': 781, 'n_tokens_neox': 783, 'n_words': 189}