How to fetch array data from a table using aggregate

Hello Guys, i am having issue with getting data that $match value in an array and get those data by array or Object

This is the document that i want to fetch data from
{
“_id”: {
“$oid”: “62908343716f52001696cc9b”
},
“wards”: [
{
“admissionNumber”: “Sil 0020”,
“schoolCode”: “SC227043”
},
{
“admissionNumber”: “Sil 0023”,
“schoolCode”: “SC227043”
}
],
“verify”: false,
“regPoint”: 4,
“completeRegistration”: true,
“email”: “”,
“schoolId”: {
“$oid”: “624f9790a900d000165b543e”
},
“password”: “$2a$10$60aNQeReDfHohft1P5WDjuWwfvCtJZlr.7sjUbDU8K8TpQgs5U1oG”,
“__v”: 0,
“otp”: “3654”,
“phoneNumber”: “8028944791”,
“address”: “22 apata alakia ibadan”,
“firstName”: “taiwo”,
“lastName”: “omotola”,
“about”: “life”,
“imgUri”: “”
}

{
“_id”: {
“$oid”: “6290958b767b9000169383e9”
},
“wards”: [
{
“admissionNumber”: “HOG001”,
“schoolCode”: “H223302”
},
{
“admissionNumber”: “HOG0010”,
“schoolCode”: “H223302”
}
],
“verify”: false,
“regPoint”: 4,
“completeRegistration”: true,
“email”: “olayemi@mail.com”,
“schoolId”: {
“$oid”: “621f990511e2b40016a22fad”
},
“password”: “$2a$10$xWbINEzm/NvyQw0CWKKsMukxnvh2UC1MjKKoOjb5QtuATuYeI8f52”,
“__v”: 0,
“otp”: “7509”,
“phoneNumber”: “8067410631”,
“address”: “60 association road”,
“firstName”: “olayemi”,
“lastName”: “williams”
}
and so on.

i want to get all the data of any student that his/her admissionNumber $match
Dia001
Dia002
DI001
BHS00200
BHS00100
BHS00300
dia007
FTS00400
HOG001
HOG002
HOG003
HOG004

Please i need to explain further, kindly help me

Please read Formatting code and log snippets in posts and update your post so that we see more clearly your issue.

i have 4 tables,
(1) wards
(2) Guardians
(3) Birthday
(4) Teacher.

I used aggregate function to get all the wards which their birthday will be comming in the next 7 days. and inserting it in the birthday table using node schedular. (This is working perfectly) at the process of getting those wards details, i need to send notification to both teacher and Guardian that has relationship with those wards that will be having birthday…

The only mean i can use to get Guardian details to receive the notification is by checking the guadians table and get each guardian for each student…and same thing with Teacher.

the table is as follows

Wards Table
{
“_id”: {
“$oid”: “6209599e9ee1d60016315ce0”
},
“sex”: “female”,
“dateJoined”: {
“$date”: {
“$numberLong”: “1659380317083”
}
},
“roleName”: null,
“isDeleted”: false,
“levelHistory”: ,
“admissionNumber”: “Dia001”,
“firstName”: “kehinde”,
“middleName”: “”,
“lastName”: “fatokun”,
“dateOfBirth”: {
“$date”: {
“$numberLong”: “1280770043041”
}
},
“guardianContact”: “08034356783”,
“currentLevel”: “620956889ee1d60016315bfc”,
“schoolId”: “620956889ee1d60016315bf8”,
“__v”: 0
},
{
“_id”: {
“$oid”: “620959f09ee1d60016315ced”
},
“sex”: “male”,
“dateJoined”: {
“$date”: {
“$numberLong”: “1659380317083”
}
},
“roleName”: null,
“isDeleted”: false,
“levelHistory”: ,
“admissionNumber”: “Dia002”,
“firstName”: "funsho ",
“middleName”: “”,
“lastName”: “adeoye”,
“dateOfBirth”: {
“$date”: {
“$numberLong”: “1280747131521”
}
},
“guardianContact”: “08035678893”,
“currentLevel”: “620956889ee1d60016315bfa”,
“schoolId”: “620956889ee1d60016315bf8”,
“__v”: 0
}

This is where i am getting wards details from and inserting them into birthday table

so from this details, there is AdmissionNumber which stand as the relationship between the wards and the Guardian.

Guardian Table
{
“_id”: {
“$oid”: “62908343716f52001696cc9b”
},
“wards”: [
{
“admissionNumber”: “Sil 0020”,
“schoolCode”: “SC227043”
},
{
“admissionNumber”: “Sil 0023”,
“schoolCode”: “SC227043”
}
],
“verify”: false,
“regPoint”: 4,
“completeRegistration”: true,
“email”: “”,
“schoolId”: {
“$oid”: “624f9790a900d000165b543e”
},
“password”: “$2a$10$60aNQeReDfHohft1P5WDjuWwfvCtJZlr.7sjUbDU8K8TpQgs5U1oG”,
“__v”: 0,
“otp”: “3654”,
“phoneNumber”: “8028944791”,
“address”: “22 apata alakia ibadan”,
“firstName”: “taiwo”,
“lastName”: “omotola”,
“about”: “life”,
“imgUri”: “”
},
{
“_id”: {
“$oid”: “62bc10586f0d8b00163d02e2”
},
“wards”: [
{
“admissionNumber”: “HOG002”,
“schoolCode”: “H223302”
}
],
“verify”: false,
“regPoint”: 4,
“completeRegistration”: true,
“email”: ",
“schoolId”: {
“$oid”: “621f990511e2b40016a22fad”
},
“password”: “$2a$10$BFM6/58We5rMZGzg9HYNq.PW/0.AwuQ8J.TgZmqEORw3CdwNjycUm”,
“__v”: 0,
“otp”: “2268”,
“phoneNumber”: “8029313116”,
“address”: “lagos”,
“firstName”: “simon”,
“lastName”: “simon”
}

with this table, i need to get all the guardians detail that has relationship with the wards that will be having birthday next weeks.
Below is the output of adminssioinNumber comming from the aggregate that i used to get the wards details
“Dia001
Dia002
DI001
BHS00200
BHS00100
BHS00300
dia007
FTS00400
HOG001
HOG002
HOG003
HOG004”.

All i need to do is to use this admission numbers to check all the guardians that has a relationship with these number, and get their details out. Thank You

Have you tried to cut-n-paste back your sample documents?

We cannot because the quotes are wrong so please:

sample document for guardian is

{
“_id”: {
“$oid”: “62908343716f52001696cc9b”
},
“wards”: [
{
“admissionNumber”: “Sil 0020”,
“schoolCode”: “SC227043”
},
{
“admissionNumber”: “Sil 0023”,
“schoolCode”: “SC227043”
}
],
“verify”: false,
“regPoint”: 4,
“completeRegistration”: true,
“email”: “kehindefayenuwo@yahoo.com”,
“schoolId”: {
“$oid”: “624f9790a900d000165b543e”
},
“password”: “$2a$10$60aNQeReDfHohft1P5WDjuWwfvCtJZlr.7sjUbDU8K8TpQgs5U1oG”,
“__v”: 0,
“otp”: “3654”,
“phoneNumber”: “8028944791”,
“address”: “22 apata alakia ibadan”,
“firstName”: “taiwo”,
“lastName”: “omotola”,
“about”: “life”,
“imgUri”: “https://res.cloudinary.com/asm-web/image/upload/v1654100090/ukv0qydhcpsfu1ssg7nd.jpg
}

and sample document for ward is this

{
“_id”: {
“$oid”: “6209599e9ee1d60016315ce0”
},
“sex”: “female”,
“dateJoined”: {
“$date”: {
“$numberLong”: “1659380317083”
}
},
“roleName”: null,
“isDeleted”: false,
“levelHistory”: ,
“admissionNumber”: “Dia001”,
“firstName”: “kehinde”,
“middleName”: “”,
“lastName”: “fatokun”,
“dateOfBirth”: {
“$date”: {
“$numberLong”: “1280770043041”
}
},
“guardianContact”: “08034356783”,
“currentLevel”: “620956889ee1d60016315bfc”,
“schoolId”: “620956889ee1d60016315bf8”,
“__v”: 0
}