<commit_before>Clubs = new Mongo.Collection('clubs');

Clubs.allow({
	insert: function(userId, doc) {
		// the user must be logged in, and the document must be owned by the user
		return (userId && doc.createdBy === userId);
	},
	update: function(userId, doc, fields, modifier) {
		// can only change your own documents
		return doc.createdBy === userId;
	},
	remove: function(userId, doc) {
		// can only remove your own documents
		return doc.createdBy === userId;
	},
	fetch: ['createdBy']
});

Clubs.deny({
	update: function(userId, docs, fields, modifier) {
		// can't change author
		return _.contains(fields, 'createdBy');
	}
});

Meteor.methods({
	clubInsert: function(clubInfos) {
		var clubId = Clubs.insert(clubInfos);
		return {
			_id: clubId
		};
	},
	createNewTeam: function(team, club) {
		Clubs.update({
			_id: club
		}, {
			$push: {
				teams: team
			}
		});
	},
	deleteTeam: function(teamToDelete) {
		Clubs.update({
			_id: teamToDelete.club
		}, {
			$pull: {
				teams: {
					teamId: teamToDelete.team
				}
			}
		});
	}
});<commit_msg>Add method the update a team<commit_after>Clubs = new Mongo.Collection('clubs');

Clubs.allow({
	insert: function(userId, doc) {
		// the user must be logged in, and the document must be owned by the user
		return (userId && doc.createdBy === userId);
	},
	update: function(userId, doc, fields, modifier) {
		// can only change your own documents
		return doc.createdBy === userId;
	},
	remove: function(userId, doc) {
		// can only remove your own documents
		return doc.createdBy === userId;
	},
	fetch: ['createdBy']
});

Clubs.deny({
	update: function(userId, docs, fields, modifier) {
		// can't change author
		return _.contains(fields, 'createdBy');
	}
});

Meteor.methods({
	clubInsert: function(clubInfos) {
		var clubId = Clubs.insert(clubInfos);
		return {
			_id: clubId
		};
	},
	createNewTeam: function(team, club) {
		Clubs.update({
			_id: club
		}, {
			$push: {
				teams: team
			}
		});
	},
	deleteTeam: function(teamToDelete) {
		Clubs.update({
			_id: teamToDelete.club
		}, {
			$pull: {
				teams: {
					teamId: teamToDelete.team
				}
			}
		});
	},
	updateTeam: function(team, club, teamId) {
		var teamToUpdate = 'teams.' + teamId;
		Clubs.update({
			_id: club
		}, {
			$pull: {
				teams: {
					teamId: teamId
				}
			}
		});
		Clubs.update({
			_id: club
		}, {
			$push: {
				teams: team
			}
		});
	}
});
{'fraction_non_alphanumeric': 0.1543261231281198, 'fraction_numerical': 0.0, 'mean_word_length': 3.111111111111111, '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': '6505499', 'n_tokens_mistral': 1003, 'n_tokens_neox': 874, 'n_words': 212}