Currently I store the relationship id by just passing the related model id, for example:
{
"_id": ObjectId("5ff7fcf93e2c5a4462b1e619"),
"text": "This is a comment.",
"userId": "5ff7fbc93e2c5a4462b1e612"
}
However, in some examples or tutorials on the internet I see the relationship like this:
{
"_id": ObjectId("5ff7fcf93e2c5a4462b1e619"),
"text": "This is a comment.",
"userId": ObjectId("5ff7fbc93e2c5a4462b1e612")
}
Putting the relationship inside ObjectId("5ff7fbc93e2c5a4462b1e612")
or simply the direct id 5ff7fbc93e2c5a4462b1e612
, does it make any difference to query performance?
I am not aware of methods to do this test. I would like to know the opinion of those who work with mongodb. One observation is that I’m using mongodb in laravel.
Marcos Nobrega is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.