Help with aggregation

I have 2 collections that are in the same DB.
See examples of documents:

  1. A collection called cavity and the second collection called test
    These are the documents for example:

***cavity-
{
“_id”: {
“$oid”: “656965e7a4353114cceaf4de”
},
“rmt_srv”: {
“ip”: “192.168.14.247”,
“host”: “”,
“pn”: “1185_MINI_GW_GSM_M_B02”,
“os”: “”,
“location”: “afula”
},
“develop”: true,
“time”: {
“$date”: “2023-12-01T06:49:43.489Z”
},
“pn_cfg”: “7602480”,
“cavity”: “1”,
“type”: “finish”,
“_exec_st”: {
“$oid”: “65696593a4353114cceaf499”
},
“_log”: “e9d1f95f-9591-446b-a7f5-faa1f3993079”,
“cavity_st”: {
“$date”: “2023-12-01T06:48:19.924Z”
},
“batch”: “”,
“pass”: true,
“_cav_st”: {
“$oid”: “65696593a4353114cceaf49a”
},
“user”: “tst”,
“faulty_test_name”: null,
“_cfg”: “647c4e796a3de000018dfb4a”,
“duration”: 83565,
“pn_cfg_rev”: “4762”,
“serial”: “11161804”,
“dut”: {
“pn”: “0634480”,
“model”: “PROG GATEWAY-S5”,
“rev”: “4A2”,
“desc”: “PROG CUBE SAS-Security-Gateway Fibocom”
},
“production_step”: “debug”
}

***test-
{
“_id”: {
“$oid”: “65684c158d00894df459145b”
},
“rmt_srv_pn”: “TF_1197_FW2_GBD_B”,
“fail”: [
“11209845”,
“11211548”,
“11209882”,
“11076777”,
“11076768”,
“11209903”,
“11211528”
],
“pass”: [
“11238822”,
“11076764”,
“10569751”
],
“total”: 10,
“stage_id”: “06-Board level”,
“serial_combined”: {
“10569751”: “pass”,
“11076764”: “pass”,
“11076768”: “fail”,
“11076777”: “fail”,
“11209845”: “fail”,
“11209882”: “fail”,
“11209903”: “fail”,
“11211528”: “fail”,
“11211548”: “fail”,
“11238822”: “pass”
},
“serials_return_period”:
}

****I need help writing an aggregation that will do the following:

  1. You will receive a time range from date to date and perform a scan of all the serial_combined and search in the collection of the cavity if those serials exist, if so write the one that exists in a new field

All my attempts didn’t work

Please update your post after reading