Can MongoDB populate () be so related?

  node.js, question

clipboard.png

clipboard.png
How can these two be related to find the corresponding _id data in figure 2

Note: sensor_id in fig. 1 is associated with _id in fig. 2

$lookupIt seems to be the function you are looking for. Look at the examples in the document, it is quite intuitive. But pay attention to one thingfromCannot be a shard set.
In addition, there is another optiondbrefAlthough the data structure in your question is not exactly the same, a slight modification is also one of the options. The difference is thatdbrefAn additional query is required to find the connected data, and it is a 1-to-1 relationship. Poor efficiency, but not limited by fragmentation. Select as needed.