I
I
igorperciuleac2014-04-26 18:26:12
MongoDB
igorperciuleac, 2014-04-26 18:26:12

How to do a search in MongoDB as a result of a search?

Is it possible to do a MongoDB lookup as the result of another lookup?
Something like this:
db.table.find({...}).find({...})

Answer the question

In order to leave comments, you need to log in

4 answer(s)
C
CAMOKPYT, 2014-04-26
@CAMOKPYT

1310428349083_0.png

O
overmes, 2014-04-26
@overmes

You can use aggregation framework
db.col.aggregation({$match:{}},{$match:{}})
will be exactly what you need

A
Arkady Butermanov, 2014-04-26
@Arkadey

I'm afraid to ask: why do you need it? It is possible to unite in one find ().
In general, the find() method returns a cursor object. Methods available on this object: docs.mongodb.org/manual/reference/method/js-cursor
As you can see, the find() method is not among them. So the answer is - You can't do that.

I
igorperciuleac, 2014-04-26
@igorperciuleac

A simple abstract example: we have a database of a million records. And there is a big loop:

for x in range(1 000):
    db.table.find({...}) // При каждой итерации делаем выборку из миллиона записей

But it is possible to pre-filter this million records before the cycle. Thus, a base of 100 records will be obtained, according to which it will be easier to do further searches in a cycle.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question