Hi Everyone,
Please suggest me alternative for findfoldersbyname() function.
Discussion posts and replies are publicly visible
The functions findFoldersByName and findDocumentByName don't scale once you have hundreds of thousands of documents - I've seen returns from these functions of 7 or more seconds; pretty bad.
The short answer is store the folder and/or document ID in the database. However, if you absolutely must retrieve, for example, the documents within a folder, it's possible to write an expression that does something similar - see below. Note that the same principle can be applied to finding a folder by name within a specific folder.
load( local!allFolderDocuments: fn!getdocumentsfromfolder( ri!folder, false ), local!allFolderDocumentNames: a!forEach( items: local!allFolderDocuments, expression: document( fv!item, "name" ) ), index( index( local!allFolderDocuments, wherecontains( ri!documentName, local!allFolderDocumentNames ), tointeger( {} ) ), 1, null ) )