I'm using Nest.JS and TypeORM. I have two entity types: File and Folder (As you can imagine, they represent files and folders on a hard drive).
Example of Folder entity:
{
id: 'aaa',
name: 'home',
childFolders: [],
files: []
}
example of File entity:
{
id: 'iii',
name: 'spreadsheet.csv',
size: 236434,
}
I have JSON from a DB which represents filesystem structure structure. For example:
{
id: 'aaa',
name: 'home',
childFolders: [
{
id: 'bbb',
name: 'bob',
childFolders: [],
files: [
{
id: 'iii',
name: 'spreadsheet.csv',
size: 236434,
}
]
}
],
files: []
}
I am building an opengraph API to be able to search for files/folders. If I want to convert this JSON into a collection of folder and file entities, will I have to loop recursively and build these entities manually? Or is there an easier way to do that?
Thank you so much for any insight you can provide.