Appreciate the update, @zean_validated! I couldn't remember if this was an insert
or update
operation.
I'm still trying to narrow down exactly where the issue here is occurring - if it's a limitation of the Extended JSON syntax as it pertains to document creation or the result of typecasting/parsing that is happening on the Retool side.
In the meantime, my recommendation is to just construct the entire document JSON within curly braces. This allows you to perform fairly complex conditionals as long as you only need access to data within Retool.
For more complex objects, you could even move all the logic for constructing the document into a separate JS query. I'll provide an update here when I have a more concrete answer about using MongoDB aggregates and other functions but hopefully this unblocks you for the time being!