R
R
Rag'n' Code Man2021-08-30 23:25:20
MongoDB
Rag'n' Code Man, 2021-08-30 23:25:20

Is such a "$lookup" possible in MongoDB?

I have a student document and it has a notes field.
I want to separate these notes into a separate collection, but I don't want to copy the id of this note into this array to the student.

I would like these notes to have, for example, an owner_id, and this array would contain only those notes whose owner_id matches the student's id.

Is it possible to do this without aggregation (I use mongoose), and in principle, is it at least possible with it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Masson, 2021-08-31
@pumbasl

You can at least make a second request to the collection with notes, find an array of student records, and insert them into the answer manually

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question