Query a document and its nested array
up vote
1
down vote
favorite
Using MongoDB and Groovy language
Having documents in a collection like the following
id: 1,
name: John,
kids: [
name: Helen,
age: 13
,
name: George,
age: 8
]
How i can make a query like
db.collection.find(name: John AND kids name: Helen)
mongodb groovy
add a comment |
up vote
1
down vote
favorite
Using MongoDB and Groovy language
Having documents in a collection like the following
id: 1,
name: John,
kids: [
name: Helen,
age: 13
,
name: George,
age: 8
]
How i can make a query like
db.collection.find(name: John AND kids name: Helen)
mongodb groovy
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Using MongoDB and Groovy language
Having documents in a collection like the following
id: 1,
name: John,
kids: [
name: Helen,
age: 13
,
name: George,
age: 8
]
How i can make a query like
db.collection.find(name: John AND kids name: Helen)
mongodb groovy
Using MongoDB and Groovy language
Having documents in a collection like the following
id: 1,
name: John,
kids: [
name: Helen,
age: 13
,
name: George,
age: 8
]
How i can make a query like
db.collection.find(name: John AND kids name: Helen)
mongodb groovy
mongodb groovy
edited Nov 9 at 13:33
asked Nov 9 at 12:18
George Vardikos
1,229417
1,229417
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You can do something like this:
mongoCommand
db.collectionName.find(
$and: [
"name" : "John",
"kids.name": "Helen"
]
)
groovy
db.collection.find(new BasicDBObject(['name' : "John", 'kids.name' :"Helen"])).toArray().each
println it
if you have any question feel fre to ask
This is not Groovy language, the question is about groovy language
– George Vardikos
Nov 9 at 13:36
1
sorry: please check updated answer)
– andranikasl
Nov 9 at 14:10
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can do something like this:
mongoCommand
db.collectionName.find(
$and: [
"name" : "John",
"kids.name": "Helen"
]
)
groovy
db.collection.find(new BasicDBObject(['name' : "John", 'kids.name' :"Helen"])).toArray().each
println it
if you have any question feel fre to ask
This is not Groovy language, the question is about groovy language
– George Vardikos
Nov 9 at 13:36
1
sorry: please check updated answer)
– andranikasl
Nov 9 at 14:10
add a comment |
up vote
0
down vote
You can do something like this:
mongoCommand
db.collectionName.find(
$and: [
"name" : "John",
"kids.name": "Helen"
]
)
groovy
db.collection.find(new BasicDBObject(['name' : "John", 'kids.name' :"Helen"])).toArray().each
println it
if you have any question feel fre to ask
This is not Groovy language, the question is about groovy language
– George Vardikos
Nov 9 at 13:36
1
sorry: please check updated answer)
– andranikasl
Nov 9 at 14:10
add a comment |
up vote
0
down vote
up vote
0
down vote
You can do something like this:
mongoCommand
db.collectionName.find(
$and: [
"name" : "John",
"kids.name": "Helen"
]
)
groovy
db.collection.find(new BasicDBObject(['name' : "John", 'kids.name' :"Helen"])).toArray().each
println it
if you have any question feel fre to ask
You can do something like this:
mongoCommand
db.collectionName.find(
$and: [
"name" : "John",
"kids.name": "Helen"
]
)
groovy
db.collection.find(new BasicDBObject(['name' : "John", 'kids.name' :"Helen"])).toArray().each
println it
if you have any question feel fre to ask
edited Nov 9 at 14:11
answered Nov 9 at 13:29
andranikasl
2644
2644
This is not Groovy language, the question is about groovy language
– George Vardikos
Nov 9 at 13:36
1
sorry: please check updated answer)
– andranikasl
Nov 9 at 14:10
add a comment |
This is not Groovy language, the question is about groovy language
– George Vardikos
Nov 9 at 13:36
1
sorry: please check updated answer)
– andranikasl
Nov 9 at 14:10
This is not Groovy language, the question is about groovy language
– George Vardikos
Nov 9 at 13:36
This is not Groovy language, the question is about groovy language
– George Vardikos
Nov 9 at 13:36
1
1
sorry: please check updated answer)
– andranikasl
Nov 9 at 14:10
sorry: please check updated answer)
– andranikasl
Nov 9 at 14:10
add a comment |
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53225590%2fquery-a-document-and-its-nested-array%23new-answer', 'question_page');
);
Post as a guest
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
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
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