I want to implement a minor file system like collection in MongoDB .
So say my object looks like this
{
"\":{
'autoexec.bat':{
name:'autoexec',
filetype:'bat',
size:1302
},
'users':{ /* its own tree */ },
'windows':{
'system':{
'autoexec.bat':{
name:'autoexec',
filetype:'bat',
size:1302123
}
}
}
}
I am wondering how to find the term ‘autoexec.bat’ in the most effiecient manner , Further for a file tree is there any better way to implement the same in Node.js or C++ ? I wish to implement features like search etc.
I’d say: don’t do this in one gigantic document. Let each file be its own document in a collection, with references to parent and (probably) children. Almost all operations are now trivial. You only have to think about efficient way to read/delete the whole tree.