I’m working on a computer science project comparing the performance of various databases for a simple Todo-App.
The key aspect is that To-Do’s are stored in a tree like structure, where one Todo can have zero or more Todos as children.
I’ve come across https://docs.mongodb.com/manual/applications/data-models-tree-structures/ where a few ways of doing this are presented.
My question is if there is a way to query (and modify) Todos stored in a User collection like this,
where a document of this collection has a property todos which stores a list of todos, and with todos under those in a children array. I hope the following document explains it better than i’m able to.
{
"_id": {
"$oid": "62347d38b8a4376e1bc67029"
},
"username": "Jan.Ntuli",
"name": "Jan Ntuli",
"email": "janntuli754@tiscali.net",
"todos": [{
"name": "Ducimus error voluptate consectetur quiaz.",
"description": "",
"moment": {
"$date": "2022-04-20T21:40:50.638Z"
},
"priority": 29,
"_id": {
"$oid": "62347d38b8a4376e1bc67064"
},
"children": [{
"name": "Maiores ullam repellat reiciendis, nz.",
"description": "",
"moment": {
"$date": "2022-04-15T02:46:01.336Z"
},
"priority": 20,
"_id": {
"$oid": "62347d38b8a4376e1bc67065"
},
"children": [],
}, {
"name": "Nihil asperiores laborum aliquid ipsum a v.",
"description": "",
"moment": {
"$date": "2022-03-24T03:49:36.894Z"
},
"priority": 20,
"_id": {
"$oid": "62347d38b8a4376e1bc67066"
},
"children": [{
"name": "Est quasi error numquam,a.",
"description": "",
"moment": {
"$date": "2022-04-16T18:22:36.173Z"
},
"priority": 10,
"_id": {
"$oid": "62347d38b8a4376e1bc67067"
},
"children": [],
}, {
"name": "Cum exercitationi.",
"description": "",
"moment": {
"$date": "2022-04-09T06:59:18.891Z"
},
"priority": 32,
"_id": {
"$oid": "62347d38b8a4376e1bc67068"
},
"children": [],
}, {
"name": "Sed sunt dicta ipsum vel im.",
"description": "",
"moment": {
"$date": "2022-04-04T10:30:05.196Z"
},
"priority": 78,
"_id": {
"$oid": "62347d38b8a4376e1bc67069"
},
"children": [{
"name": "Aliquid hic rerum fugit dom.",
"description": "Possimus consen.",
"moment": {
"$date": "2022-03-21T21:03:11.587Z"
},
"priority": 11,
"_id": {
"$oid": "62347d38b8a4376e1bc6706a"
},
"children": [],
}, {
"name": "Vel aut qui quia cum. Magnam exercn.",
"description": "",
"moment": {
"$date": "2022-04-01T08:55:54.262Z"
},
"priority": 86,
"_id": {
"$oid": "62347d38b8a4376e1bc6706b"
},
"children": [],
}],
}, {
"name": "Facilis quos omnis u.",
"description": "Voluptate consectei.",
"moment": {
"$date": "2022-04-13T17:06:12.311Z"
},
"priority": 5,
"_id": {
"$oid": "62347d38b8a4376e1bc6706c"
},
"children": [],
}, {
"name": "Quia exercitap.",
"description": "",
"moment": {
"$date": "2022-04-03T23:48:30.433Z"
},
"priority": 29,
"_id": {
"$oid": "62347d38b8a4376e1bc6706d"
},
"children": [],
}],
}],
}],
}
The question is if it’s possible to, for example, find a todo with a certain name (“Quia exercitap.”) without knowing the depth it is at.