0

We have documents in a container with Parent child relation, I wanted to join these items if I pass inner folder id(FolderId = 3), it should return all parents as well.

Item 1 { "FolderId": "1", "FolderName": "Folder 1", "ParentFolderId": null }

Item 2 { "FolderId": "2", "FolderName": "Folder 2", "ParentFolderId": 1, }

Item 3 { "FolderId": "3", "FolderName": "Folder 3", "ParentFolderId": 2, }

Akhil Tyagi
  • 71
  • 2
  • 6

1 Answers1

0

You are basically trying to join multiple documents in Cosmos DB which is not supported. You either need to change the way you create documents by having all the parent-child relations in single document, or get all the documents on client side through any SDK and then apply the logic through code.

Please refer below links for more details:

  1. CosmosDB Join (SQL API)
  2. https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/6611247-support-cross-document-joins
  • Yes we can have in single document but inner child folders can be added n number of times, It may breach maximum document size & need to update single document every time. Is there any better approach. – Akhil Tyagi Aug 11 '20 at 14:07
  • So currently the max document size is 2 MB in Cosmos db which itself is big enough, but it can still be crossed as you mentioned and needs constant updates in case you want to add more to same document. The best way in that case could be to retrieve the result on client and play around whichever way wanted. – AnuragSharma-MSFT Aug 12 '20 at 05:27