Sign In Register

How can we help you today?

Start a new topic

Access collections as variable through module in cloud code

Hi,


I'd like to be able to create a module that would contains all the collection names. I would then like to be able to assign the variable from the module in the cloud code event.


For example:

Spark.runtimeCollection(variableNameFromModule).remove({ "_id" : { "$oid" : itemsToRemove.next()._id.$oid }});


Is it possible?


I've seen that we can use function and I already do that, but I was wondering the syntax for the variable. It could also be like an enum.


Thanks!

1 Comment

Hi Pr, 


Given that any RuntimeCollection related operations simply take a string identifier for the collection in question, these can be stored in a module as const strings if necessary. This would allow you to maintain a reference to said collections shortcodes if you would prefer that over hardcoding strings in your script. 


Best Regards, Patrick. 

Login to post a comment