INSERT / UPDATE not inserting / updating

I have the following function:

function newnode(five, context, result)  {
     return five.createError(result, JSON.stringify(five.executeQuery('INSERT INTO nodes (nodesKey, nodesUser) VALUES ("' + context.nodekeytomake + '", "' + five.currentUserKey() + '");')));
}

it runs and returns normally but I dont see any change in the table nodes.

i have a similar situation with an update function running but not updating.

am I doing something wrong?

Hi Toshi,

Where is the function being called? If it is connected to an On… event it is being executed on the client side and if it is a Do… event it is being called on the server side. You can only perform SQL on a server side function due to security restrictions so if it is being called client side it will not do anything.

As an option you could create a new function called newnodeserver which contains the SQL and then call five.executeFunction() within newnode to execute it on the back end.

Hope this helps!

Mark

i get this error:

TypeError: five.executeFunction is not a function > newnodeserver.fs.js:2:30

Hi Toshi,

Can you send through the full code of the function and which event it is being called from?

Thanks

Mark

If you would prefer not to post the code here please send it to support@five.co and we will reply there.

Mark

Thank you., i solved it by calling executeAction instead from newnodeserver and calling a custom process similar to this: How to automate INSERT INTO