Mongodb Subquery?

446 views
Skip to first unread message

Porlaotracara

unread,
Sep 8, 2014, 11:27:32 AM9/8/14
to mongod...@googlegroups.com
I have a collection of thousands of documents. Each document has 5 fields (fields: _id, Name, Event, Phone, City).

Each name (The names are repeated) has multiple events. I made a query where I get all "name" with "event" = "A".

Now I want to make another query to call the previous query. Is this possible with Mongodb?


On the other hand ... 

If I have a collection of thousands of documents (fields: name, age ...) and I have a list of 500 names, and I just want to do the query on those 500 names. What would I do?


Thx.

Will Berkeley

unread,
Sep 8, 2014, 12:49:37 PM9/8/14
to mongod...@googlegroups.com
What are you trying to do exactly? How are you envisioning a query that calls another query will work and what will it accomplish for you? There isn't a strict analogue to "subqueries" in SQL in MongoDB but I need to know more about what you want to accomplish to help you.

For the second question, what does it mean to "do the query on those 500 names"? You only want results whose name field is one of the 500 values, in addition to other query restrictions? An example would be helpful.

-Will

Jorge Guerrero

unread,
Sep 8, 2014, 4:55:07 PM9/8/14
to mongod...@googlegroups.com
You wan't to do a "second query" over the result of the first one?

http://docs.mongodb.org/manual/core/aggregation-introduction/
Reply all
Reply to author
Forward
0 new messages