I would like to compare two arrays in find() method. I did do that but it doesn seem to work :
var userOne = group.users[0];
var userTwo = group.users[1];
const selector = {
$and: [{
$or: [{
'users[0]': userOne
}, {
'users[0]': userTwo
}]
}, {
$or: [{
'users[1]': userOne
}, {
'users[1]': userTwo
}]
}, {
type: 0
}]
};
var exists = Groups.find(selector).fetch();
console.log(exists);
When userOne and userTwo exist, it doesnt return anything, but when one of them is undefined it returns all the collection.
Someone can help me please ?
Note: Ths schema of the collection is :
GroupsSchema = new SimpleSchema({
name: {
type: String,
optional: true
},
description: {
type: String,
optional:true
},
type: {
type: Number
},
users: {
type: [String],
optional: true
} });