Save document_key as separate property



I recently ran into a problem in my current project that I don’t know how to solve.

When a user creates a new document in one of my firebase collections (called Collections) I need to be able to fetch the document_key of that collection and store it as a separate property inside the newly created collection, all in the same interaction. The reason this is needed is to make it indexible by the following query:

where(" CollectionID “, “==”, “$slot(’ ds_SelectedCollectionID ')”).orderBy(” CollectionDate ",“desc”)

This is not possible today without some sort of custom script but unfortunately I don’t know how to code. Is there anyone here that has ran into a similar scenario and knows how to solve it?

Thanks in advance