Answer the question
In order to leave comments, you need to log in
How to properly link parent and child in mongodb?
I have a fairly large tree, after reading the documentation, a solution with a parent and a child is more suitable for me. The documentation lists the following examples:
db.categories.insert( { _id: "Books", parent: null } )
db.categories.insert( { _id: "Programming", parent: "Books" } )
{
"_id": "Books",
"parent": null
}
{
"_id": "Programming",
"parent": "Books"
}
{
"_id": "Books",
"parent": null
children: [
{ "_id": "Programming",
"parent": "Books"
children: [
....
},
....
]
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question