How to build a folder structure using morphia or the mongodb API? I am looking for something like this.
folderA
--->folderB
--->folderC
------>fileC
------>folderCA
---------->fileCA
How to build a folder structure using morphia or the mongodb API? I am looking for something like this.
folderA
--->folderB
--->folderC
------>fileC
------>folderCA
---------->fileCA
OK, this type of structure should be really easy to implement.
You basically have two collections folders
and files
.
Elements in folders
have this structure:
{
"_id":mongoid,
"name":"folderA",
"properties":"etc",
...
"folders":[{"folderB":refB}, {"folderC":refC}],
"files":[{"fileA":refA}]
}
Elements in files
are really simple:
{
"_id":mongoid,
"name":"fileA",
"size":1234,
...
}
So basically a folder object is simply an object (with properties) that contains two arrays: one array of "sub-folders" and one array of "files in that folder".
The arrays could just be references, but in this case I've stored it as name and reference. This makes it easier to list at least some file information.