Is it good practice to call stored function through c# for inserting a record before checking for its existence or do the same operation through linq in c#?
for e.g
My function is below
function(productid, json) {
var exists = db.zProduct.find({"ProductId":productid, "Combinations": { $elemMatch: json }}).count()
if(exists == 0){
db.zProductMongoModel.insertOne({"ProductId":productid, "Combinations":json })
return ("New Document Created")
}
}
The above code works fine if I call the function though C# but i read from [https://docs.mongodb.com/manual/tutorial/store-javascript-function-on-server/]2
that Do not store application logic in the database.
Someone pls advise.