Why is an _id with ObjectID added to when using MongoDB’s $push to add new object to an array?

You can disable the _id field by explicitly defining the tournamentSessions array with its own schema so that you can set its _id option to false:

var Player = mongoose.model('Player', Schema({
    createdAt: { type: Date, default: Date.now },
    lastActiveAt: Date,
    clientVersion: String,
    tournamentSessions: [new Schema({
        tournament: { type: Schema.Types.ObjectId, ref: 'Tournament' },
        level: Number,
        status: String,
        score: Number
    }, { _id: false })],
    friends: Array
}));

Leave a Comment