Skip to content

Instantly share code, notes, and snippets.

@hellivan
Created September 27, 2019 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellivan/0d3ce7722d6add10eab83bbfbca52cc5 to your computer and use it in GitHub Desktop.
Save hellivan/0d3ce7722d6add10eab83bbfbca52cc5 to your computer and use it in GitHub Desktop.
Gist for reproducing an error in mongoose CoreMongooseArray.includes function
const mongoose = require('mongoose');
const personSchema = new mongoose.Schema({
name: String,
friends: [{
name: String
}]
});
const Person = mongoose.model('Person', personSchema);
const friendsList = [
{name: 'foo'},
{name: 'bar'}
];
const testPerson = new Person({
name: 'p1',
friends: friendsList
});
// should print "CoreMongooseArray.includes: false"
console.log('Array.includes: ', friendsList.map(f => f.name).includes('foo', 1));
// should print "CoreMongooseArray.includes: false"
console.log('CoreMongooseArray.includes: ', testPerson.friends.map(f => f.name).includes('foo', 1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment