I wrote the code to try DBRef Concept:
The Students Collections has:
{
"FirstName": "Omar",
"LastName": "Ali",
"IsFired": true,
"FacultyID":
{
"$ref": "Faculty",
"$id": "633d5fca2bed487dd7eb4e11",
"$db": "FacultySystemV2"
},
"CoursesList": [
{
"CourseID": {
"$oid": "633d5fd62bed487dd7eb4e14"
},
"Grade": 95
},
{
"CourseID": {
"$oid": "633d602c2bed487dd7eb4e15"
},
"Grade": 80
}
]
}
The Faculty Collections has:
{
"_id": ObjectId('633d5fca2bed487dd7eb4e11')
"FacultyName": "Alex University",
"Address": "Alex City"
}
Unfortunately, it can't recognize the $id or $ref inside the DPRef
var stds6 = db.Students.findOne({"FirstName": "Omar"})
db[stds6.FacultyID.$ref].findOne({"_id": (stds6.FacultyID.$id)})
Even if I write:
stds6.FacultyID.$ref or
stds6.FacultyID.$id I get notinge Faculty Collections has:
{
"_id": ObjectId('633d5fca2bed487dd7eb4e11')
"FacultyName": "Alex University",
"Address": "Alex City"
}
Unfortunately, it can't recognize the $id or $ref inside the DPRef
var stds6 = db.Students.findOne({"FirstName": "Omar"})
db[stds6.FacultyID.$ref].findOne({"_id": (stds6.FacultyID.$id)})
Even if I write:
stds6.FacultyID.$ref
or
stds6.FacultyID.$id
I get noting