I have Mongoose.Schema like this:
const pixelSchema = mongoose.Schema({
x: String,
y: String,
color: String,
});
Also I have array of objects like this:
let pixels = [
{x: 0, 1: 0, color: 'blue'},
{x: 0, y: 1, color: 'blue'},
{x: 0, y: 2, color: 'blue'},
]
How can I check is one of this elements is already exist in database? My solution now looks like this, but I think it's very inefficient.
pixels.map(pixel => {
Pixel.find(pixel, (err, pixels) => {
if (pixels) {
console.log('Find!');
}
});
});