How to record with a server side script?

Hello,

I wanted to know how to record datas with a server side script, because I don’t want to write my tables and fields names in my client side javascript code. Actualy to insert data for example, I do :

//Insert a record
    window.app.addThing = function(){
    var item = {"record":[
        {
            "field_1":"data_1",
            "field_2":"data_2"
        }
    ]};
        window.df.apis.myService.createRecords({"table_name":"my_table_name", "body":item}, function (response) {
            document.getElementById("post-results").innerHTML = JSON.stringify(response);
        }, function(response) {
           document.getElementById("get-results").innerHTML = window.app.getErrorString(response);
        });
    }

So my question is : How can I do it on the server, and then how can I call this from the client ?
Thank you very much,
Guillaume.

You should be able to accomplish this easily with server-side scripting. For example, create a custom script named addThing, then invoke the script from your client by calling POST /rest/system/script/addThing.

The script should be written to call platform.api.post("db/my_table_name", item), for example.

Here is the relevant documentation page:

https://github.com/dreamfactorysoftware/dsp-core/wiki/API-Access-via-Scripts

And a quick tutorial:

Hi Jeff

Following from this say I want to add userID and dateCreated to data being posted from the client - how would I do that ?

Matt