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

Teams.attachSchema(
    new SimpleSchema({
        name: {
            type: String
        },
        code: {
            type: String
        },
        createdAt: {
            type: Date,
            autoValue: function () {
                if (this.isInsert) {
                    return new Date;
                }
            },
            denyUpdate: true
        },
        updatedAt: {
            type: Date,
            autoValue: function() {
                if (this.isUpdate) {
                    return new Date();
                }
            },
            denyInsert: true,
            optional: true
        }
    })
);

if (Meteor.isServer) {
    Teams.allow({
        insert: function () {
            return true;
        },
        update: function () {
            return true;
        },
        remove: function () {
            return true;
        }
    });

    Meteor.methods({
        addTeam: function (team) {
            // Make sure the user is logged in before inserting a tea,
            //if (!Meteor.userId()) {
            //    throw new Meteor.Error("not-authorized");
            //}

            check(team, {
                name: String,
                code: String
            });

            if (Teams.findOne({code: team.code}) != null) {
                throw new Meteor.Error("team-duplicate-code", "Ein Team mit diesem Code existiert bereits!");
            }

            Teams.insert({
                name: team.name,
                code: team.code,
                createdAt: new Date()
            });
        },
        deleteTeam: function (id) {
            check(id, String);

            Teams.remove(id, function (error) {
                if (error) {
                    throw new Meteor.Error("team-remove", "Während dem Löschen ist ein Fehler aufgetreten!");
                }
            });
        },
        editTeam: function (team) {
            check(team, {
                _id: Meteor.Collection.ObjectID,
                name: String,
                code: String
            });

            if (Teams.findOne(team._id) == null) {
                throw new Meteor.Error("team-not-found", "Team nicht gefunden!");
            }

            if (Teams.findOne({code: team.code}) != null) {
                throw new Meteor.Error("team-duplicate-code", "Ein Team mit diesem Code existiert bereits!");
            }

            Teams.update(team._id, {
                    $set: {
                        name: team.name,
                        code: team.code
                    }
                }
            );
        }
    });
}<commit_msg>fixed inserting teams<commit_after>Teams = new Mongo.Collection('Teams');

Teams.attachSchema(
    new SimpleSchema({
        name: {
            type: String
        },
        code: {
            type: String
        },
        createdAt: {
            type: Date,
            autoValue: function () {
                if (this.isInsert) {
                    return new Date;
                }
            },
            denyUpdate: true,
            optional: true
        },
        updatedAt: {
            type: Date,
            autoValue: function() {
                if (this.isUpdate) {
                    return new Date();
                }
            },
            denyInsert: true,
            optional: true
        }
    })
);

if (Meteor.isServer) {
    Teams.allow({
        insert: function () {
            return true;
        },
        update: function () {
            return true;
        },
        remove: function () {
            return true;
        }
    });

    Meteor.methods({
        addTeam: function (team) {
            // Make sure the user is logged in before inserting a tea,
            //if (!Meteor.userId()) {
            //    throw new Meteor.Error("not-authorized");
            //}

            check(team, Teams.simpleSchema());

            if (Teams.findOne({code: team.code}) != null) {
                throw new Meteor.Error("team-duplicate-code", "Ein Team mit diesem Code existiert bereits!");
            }

            Teams.insert({
                name: team.name,
                code: team.code,
                createdAt: new Date()
            });
        },
        deleteTeam: function (id) {
            check(id, String);

            Teams.remove(id, function (error) {
                if (error) {
                    throw new Meteor.Error("team-remove", "Während dem Löschen ist ein Fehler aufgetreten!");
                }
            });
        },
        editTeam: function (team) {
            check(team, {
                _id: Meteor.Collection.ObjectID,
                name: String,
                code: String
            });

            if (Teams.findOne(team._id) == null) {
                throw new Meteor.Error("team-not-found", "Team nicht gefunden!");
            }

            if (Teams.findOne({code: team.code}) != null) {
                throw new Meteor.Error("team-duplicate-code", "Ein Team mit diesem Code existiert bereits!");
            }

            Teams.update(team._id, {
                    $set: {
                        name: team.name,
                        code: team.code
                    }
                }
            );
        }
    });
}
{'fraction_non_alphanumeric': 0.1124813153961136, 'fraction_numerical': 0.0, 'mean_word_length': 1.0486031381553769, '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': '3986860', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1355, 'n_words': 319}