To retrieve data by ID from the collection:
MarioChar.findOne({ _id: character._id }).then(result => {
assert(result._id === character._id)
done();
})
But the above code is not going to work as
result._id===character._id is going to return false as
result._id is of type ObjectID and character._id is of type String. So we've to convert both of them to String and then compare.
result._id.toString()===character._id.toString()
will return true
Top comments (0)