Reading the mongo docs for modeling many-to-many relationships, I see they are using simple strings for the _id
{
_id: "oreilly",
name: "O'Reilly Media",
founded: 1980,
location: "CA"
}
{
_id: 123456789,
title: "MongoDB: The Definitive Guide",
author: [ "Kristina Chodorow", "Mike Dirolf" ],
published_date: ISODate("2010-09-24"),
pages: 216,
language: "English",
publisher_id: "oreilly"
}
where I imagined it was beneficial to use actual ObjectId
values as per this question: Difference between storing an ObjectId and its string form, in MongoDB
I’m finding it complex to have to cast between the object and string as this data passes back and forth between the Frontend (Vue) and backend (NestJS/Node) as JSON and am wondering if there is any real necessity to concern myself with utilizing ObjectId
as it adds a fair bit of complexity.
Does storing the reference id as a string make any difference when performing an aggregation/$graphLookup? Am I meant to actually store this reference itself as an ObjectId or is that wholly unnecessary?