Reputation: 1089
I have the following schema:
var daySchema = new Schema({
date: {
type: Date,
required: true
},
activities: [{
type: Schema.Types.ObjectId,
ref: 'Activity'
}]
});
And I am removing an activity within the daySchema:
var index = day.activities.indexOf("584aa9c16791eb1ec4ad8e73");
day.activities.splice(index, 1);
Can someone explain me why this works ?. The array "activities" is an array of "ObjectId". So the "indexOf" should not work with objects, but still the "indexOf" is able to find the element based on the id. This is driving me crazy, is something else going on here, maybe a map function inside ObjectId ?
Upvotes: 5
Views: 6533