Created
September 27, 2019 11:21
-
-
Save hellivan/0d3ce7722d6add10eab83bbfbca52cc5 to your computer and use it in GitHub Desktop.
Gist for reproducing an error in mongoose CoreMongooseArray.includes function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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