Mongo: find all documents that match more than three items from an array [duplicate]
up vote
0
down vote
favorite
This question already has an answer here:
Mongodb count all array elements in all objects matching by criteria
2 answers
How to Count Matched array elements
1 answer
I'm trying to return documents from my "Shoe" collection if it matches three or more values from the "userTags" array.
var userTags = ["nike", "running", "blue", "Reebok", "New Balance"]
return Shoe.find({ shoeTags: { $in: userTags}});
// this will match if it contains any of the values in the array but I would like it to only return the document if it matches 3 or more values from the userTags array
mongodb
marked as duplicate by Neil Lunn
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 3:29
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
0
down vote
favorite
This question already has an answer here:
Mongodb count all array elements in all objects matching by criteria
2 answers
How to Count Matched array elements
1 answer
I'm trying to return documents from my "Shoe" collection if it matches three or more values from the "userTags" array.
var userTags = ["nike", "running", "blue", "Reebok", "New Balance"]
return Shoe.find({ shoeTags: { $in: userTags}});
// this will match if it contains any of the values in the array but I would like it to only return the document if it matches 3 or more values from the userTags array
mongodb
marked as duplicate by Neil Lunn
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 3:29
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Mongodb count all array elements in all objects matching by criteria
2 answers
How to Count Matched array elements
1 answer
I'm trying to return documents from my "Shoe" collection if it matches three or more values from the "userTags" array.
var userTags = ["nike", "running", "blue", "Reebok", "New Balance"]
return Shoe.find({ shoeTags: { $in: userTags}});
// this will match if it contains any of the values in the array but I would like it to only return the document if it matches 3 or more values from the userTags array
mongodb
This question already has an answer here:
Mongodb count all array elements in all objects matching by criteria
2 answers
How to Count Matched array elements
1 answer
I'm trying to return documents from my "Shoe" collection if it matches three or more values from the "userTags" array.
var userTags = ["nike", "running", "blue", "Reebok", "New Balance"]
return Shoe.find({ shoeTags: { $in: userTags}});
// this will match if it contains any of the values in the array but I would like it to only return the document if it matches 3 or more values from the userTags array
This question already has an answer here:
Mongodb count all array elements in all objects matching by criteria
2 answers
How to Count Matched array elements
1 answer
mongodb
mongodb
edited Nov 12 at 3:32
Neil Lunn
96.4k22169180
96.4k22169180
asked Nov 12 at 3:27
zschrief
1
1
marked as duplicate by Neil Lunn
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 3:29
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Neil Lunn
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 12 at 3:29
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes