My requirement is to create a embedded document in mongodb collection through Java and here's the structure
folder
{
_id: String, // location id
documentVersion: int,
locationDisplayName: String;
displayName: String,
subfolders: [
{
dispalyName: String,
subcategories: [
/// For Catgeory type
{
displayName: String,
subcategories: [
],
items: [
]
},
],
items: [
{
displayName: String,
itemId: String,
name: String,
code: String
},
...
],
itemId: String,
name: String,
code: String
}
],
items: [
{
displayName: String,
itemId: String,
name: String,
code: String
},
..
]
}
I am able to check the parent folder and insert subfolder at 2 levels using element match. However my sub folder can go upto level 6. How can I do the match and insert folder at correct level and also insert items into the folder