Sign In Register

How can we help you today?

Start a new topic

Insert in runtimeCollection

When I make an insert in a Spark.runtimeCollection, it should return (according documentation) true or false wether the insert succeed or fail.

If the insert leads to a duplicate key, there is a fatal error on the cloud code line and the script breaks.

I would expect to have false to be able to deal with the case.

1 person has this problem
1 Comment

Hi Eric,

You can catch this exception and return it using a try-catch block:


        //insert operation here

       var res = Spark.runtimeCollection("myCollection").insert(myDoc);



        //print error message

        res = false;




   Spark.setScriptData("result", res);

Hope this helps. If you have any more questions please don't hesitate to contact us.



Login to post a comment