D
D
Dmitry2016-06-27 17:00:56
MongoDB
Dmitry, 2016-06-27 17:00:56

Why are documents not being embedded in Mongo?

Good afternoon. Went into a dead end. Google didn't help.
There are 2 models in mongoose - Project, Payment. One-to-many relationship. There are many Payments in one Project.
52a12c285e614978b8eea61136559362.jpg
Here is the Payment model, which has a reference to the creator - the Project model.
52a12c285e614978b8eea61136559362.jpg
I want to get all Projects with Pyments embedded in them via populate();
a96933c81eae429d9fc2212d80b8a960.jpg
But instead comes an empty array.
b6e28c623efc4296bec7f282a42b00ac.jpg
When creating a Payment, I save them like this with a link to the Project
dbcbe32c737946c29a109f156b0573fb.jpg
What am I doing wrong?
By the way, if you put _ before payments in the Project model, then not an empty payments array is returned, but with payments id's.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex Kheben, 2016-07-07
@zBit

And where is the description of the Payment model?

D
Dmitry, 2016-07-07
@splirit

Already decided. When adding a new record to Payment, it was necessary not only to set the owner of the Project model to it, but also to push a new Payment to the Project.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question