Reputation: 1140
Suppose, below is the features array already exist in my database records:
const features = [
'Multiple Admin Users',
'Distribute Units',
'Unit Reports',
'Track Single Unit',
'Commercial Usage',
'Multiple Locations'
];
Below is the query I am passing in Model.findOne method.
const query = {
features: {
'$in': [
/^Multiple Admin Users$/i,
/^Multiple Locations$/i,
/^Commercial Usage$/i,
/^Distribute Units$/i,
/^Unit Reports$/i
],
'$size': 5
}
}
const existingTier = await Tier.findOne(query); //should not return document as features are not exactly matched
I want to check for feature duplication. Order of feature does not matter and features should be compared with case insensitive operation. Query should return the document if and only if all features of document are same as in query. Order and case of features doesn't matter.
Upvotes: 1
Views: 82