Azure / azure-cosmosdb-js-server

The JavaScript SDK for server-side programming in Azure Cosmos DB
MIT License
179 stars 152 forks source link

To use trigger when calling stored procedure #44

Open abhijaykh07 opened 4 years ago

abhijaykh07 commented 4 years ago

I have a scenario where I am calling stored procedure for bulkImport. So is there any option to call trigger from stored procedure while creating document ? In trigger there is a pre logic that needs to be executed before document.

abhijaykh07 commented 4 years ago

@mkolt Can you please suggest me solution for this issue ?

mkolt commented 4 years ago

calling triggers are not supported for operations within script (from sproc, in particular). Since sproc already runs in JavaScript, just execute your pre-logic and then call getContext().getCollection().createDocument(...), adding support for triggers wouldn't add much functionality, just convenience. Does this make sense?

abhijaykh07 commented 4 years ago

calling triggers are not supported for operations within script (from sproc, in particular). Since sproc already runs in JavaScript, just execute your pre-logic and then call getContext().getCollection().createDocument(...), adding support for triggers wouldn't add much functionality, just convenience. Does this make sense?

@mkolt yes that's the option left as of now, writing the trigger logic before create document in the same stored procedure.

I have also tried while calling from c# end, passing via PreTriggerInclude. But its giving me always an exception "one of the specified inputs is invalid". Do you have any idea for this issue ? But stored procedure works if I don't pass PreTriggerInclude option.

image