Find elements in mongo collection matching values from 3D-array
up vote
0
down vote
favorite
I have a MongoDB collection called crosses, and a three-dimensional array called originals.
Elements of the collection have 4 fields: number1, brand1, number2, brand2; the array looks like [[val1, val2], [val1, val2], [val1, val2], ...].
How should i write find() function to find every element of the collection with number1 matching val1 and brand1 matching val2 from the same element of originals array?
(i wanna get something like { number1: originals[n][0], brand1: originals[n][1] })
I do it with forEach method now but maybe there's another way?
javascript mongodb
add a comment |
up vote
0
down vote
favorite
I have a MongoDB collection called crosses, and a three-dimensional array called originals.
Elements of the collection have 4 fields: number1, brand1, number2, brand2; the array looks like [[val1, val2], [val1, val2], [val1, val2], ...].
How should i write find() function to find every element of the collection with number1 matching val1 and brand1 matching val2 from the same element of originals array?
(i wanna get something like { number1: originals[n][0], brand1: originals[n][1] })
I do it with forEach method now but maybe there's another way?
javascript mongodb
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a MongoDB collection called crosses, and a three-dimensional array called originals.
Elements of the collection have 4 fields: number1, brand1, number2, brand2; the array looks like [[val1, val2], [val1, val2], [val1, val2], ...].
How should i write find() function to find every element of the collection with number1 matching val1 and brand1 matching val2 from the same element of originals array?
(i wanna get something like { number1: originals[n][0], brand1: originals[n][1] })
I do it with forEach method now but maybe there's another way?
javascript mongodb
I have a MongoDB collection called crosses, and a three-dimensional array called originals.
Elements of the collection have 4 fields: number1, brand1, number2, brand2; the array looks like [[val1, val2], [val1, val2], [val1, val2], ...].
How should i write find() function to find every element of the collection with number1 matching val1 and brand1 matching val2 from the same element of originals array?
(i wanna get something like { number1: originals[n][0], brand1: originals[n][1] })
I do it with forEach method now but maybe there's another way?
javascript mongodb
javascript mongodb
asked Nov 7 at 12:05
Екатерина Тонкова
11
11
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53189137%2ffind-elements-in-mongo-collection-matching-values-from-3d-array%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown