# Documentation and Examples on Server-Side Scripting

**URL:** <https://community.dreamfactory.com/t/documentation-and-examples-on-server-side-scripting/66>\
**Category:** Server-Side Scripting\
**Created:** [May 28, 2014, 12:26am UTC](https://community.dreamfactory.com/t/documentation-and-examples-on-server-side-scripting/66 "2014-05-28T00:26:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [May 28, 2014, 12:26am UTC](https://community.dreamfactory.com/t/documentation-and-examples-on-server-side-scripting/66/1 "2014-05-28T00:26:37Z")

</div>

DreamFactory provides a server-side event system and server-side scripting with Javascript. In addition, you can set up security rules on the backend with lookup keys and server-side filters. Below are links to the docs and some blog posts which illustrate typical use cases.

### Docs

- [Server-Side Events](https://github.com/dreamfactorysoftware/dsp-core/wiki/Server-Side-Events)
- [Server-Side Scripting](https://github.com/dreamfactorysoftware/dsp-core/wiki/Server-Side-Scripting)
- [Scripting API Access](https://github.com/dreamfactorysoftware/dsp-core/wiki/API-Access-via-Scripts)
- [Lookups and System Variables](https://github.com/dreamfactorysoftware/dsp-core/wiki/Lookups-and-System-Variables)
- [Server-Side Filters](https://github.com/dreamfactorysoftware/dsp-core/wiki/Server-Side-Filters)

### Blogs

- [DreamFactory 1.5 Introduces Server-Side Scripting](https://blog.dreamfactory.com/dreamfactory-introduces-server-side-scripting)
- [How to Write Custom Scripts](https://blog.dreamfactory.com/build-your-own-web-services-using-dreamfactory-custom-scripts)
- [DreamFactory 1.5 Introduces Lookup Keys](https://blog.dreamfactory.com/dreamfactory-introduces-lookup-keys)
- [DreamFactory 1.5 Introduces Server-Side Filters](https://blog.dreamfactory.com/dreamfactory-introduces-server-side-filters)
- [Data Segmentation with Server-Side Filtering and Lookup Keys](https://blog.dreamfactory.com/data-segmentation-with-server-side-filtering-and-lookup-keys)

---

<div class="post-metadata">

**Author:** ![Jason\_Whalan](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@Jason\_Whalan](https://community.dreamfactory.com/u/Jason_Whalan)\
**Post date:** [February 18, 2016, 4:34am UTC](https://community.dreamfactory.com/t/documentation-and-examples-on-server-side-scripting/66/2 "2016-02-18T04:34:39Z")

</div>

Hi I have noticed all of the docs which used to be in Github are now gone. Is there any way to access these again?

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [February 18, 2016, 5:15am UTC](https://community.dreamfactory.com/t/documentation-and-examples-on-server-side-scripting/66/3 "2016-02-18T05:15:22Z")

</div>

No, we made the 1.x documentation private because it was causing a lot of confusion now that DreamFactory 2.0 shipped. The latest documentation for DreamFactory 2.x is here [https://wiki.dreamfactory.com/Main\_Page](https://wiki.dreamfactory.com/Main_Page).

---

<div class="post-metadata">

**Author:** ![Jason\_Whalan](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@Jason\_Whalan](https://community.dreamfactory.com/u/Jason_Whalan)\
**Post date:** [February 18, 2016, 9:18pm UTC](https://community.dreamfactory.com/t/documentation-and-examples-on-server-side-scripting/66/4 "2016-02-18T21:18:39Z")

</div>

So no way to access? I am hoping they might hold the answer to what I am looking for. The 2.0 docs don’t.

---

<div class="post-metadata">

**Author:** ![benbusse](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/benbusse/32/4_2.png) [@benbusse](https://community.dreamfactory.com/u/benbusse)\
**Post date:** [February 18, 2016, 9:28pm UTC](https://community.dreamfactory.com/t/documentation-and-examples-on-server-side-scripting/66/5 "2016-02-18T21:28:45Z")

</div>

What’s the specific question? We’ll try to answer on this thread.

---

<div class="post-metadata">

**Author:** ![Jason\_Whalan](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@Jason\_Whalan](https://community.dreamfactory.com/u/Jason_Whalan)\
**Post date:** [February 18, 2016, 11:27pm UTC](https://community.dreamfactory.com/t/documentation-and-examples-on-server-side-scripting/66/6 "2016-02-18T23:27:27Z")

</div>

Thanks Ben. My question is located here. I don’t know if I worded that well enough not to confuse but hopefully you will understand what I am trying to achieve. [LINK HERE](https://community.dreamfactory.com/t/display-items-based-on-child-data-or-modify-data-based-on-child-data/2216)

But to simplify it a little say I have script the following event script wp\_postmeta.get.post\_process

```
if (event.response.record) {
    _.each(event.response.record, function (record, index, list) {
        if (record.meta_key == "_end_ts"){
            record.endseconds = record.meta_value;
        }
        if (record.meta_key == "_start_ts"){
            record.startseconds = record.meta_value;
        }
});
}

```

This table (wp\_postmeta) is a child of the wp\_posts table. So when I call a GET on **wp\_postmeta** I get the modified data but when I call a GET on **wp\_posts** and I include it’s relationships the wp\_postmeta data (or wp\_postmeta\_by\_id) is not modified. How can I have the above script do it’s work on the postmeta data whilst calling a GET on wp\_posts?

Any clue you could give or direction you could point me would be hugely appreciated.

For example if I do a platform.api.get on the wp\_postmeta table within another script how can I go about iterating over this data as we do in an event script with the \_each function?

Thanks heaps.

---

<div class="post-metadata">

**Author:** ![leehicks](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/leehicks/32/55_2.png) [@leehicks](https://community.dreamfactory.com/u/leehicks)\
**Post date:** [February 19, 2016, 1:50am UTC](https://community.dreamfactory.com/t/documentation-and-examples-on-server-side-scripting/66/7 "2016-02-19T01:50:21Z")

</div>

Same answer here will apply to 2.x as well. There is no direct way to apply child table scripts to parent table queries, reason being is because related queries don’t trigger an event for child tables. Currently you will have to write a script on the parent table and loop through each of the child records of each parent record.

---

<div class="post-metadata">

**Author:** ![Jason\_Whalan](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@Jason\_Whalan](https://community.dreamfactory.com/u/Jason_Whalan)\
**Post date:** [February 19, 2016, 3:22am UTC](https://community.dreamfactory.com/t/documentation-and-examples-on-server-side-scripting/66/8 "2016-02-19T03:22:01Z")

</div>

Thanks for your response. Do you have any idea how I might do that. I am unsure how to loop through those having tried things such as

var filter\_data = {“filter”: “blahblah”};  
var REQUEST = platform.api.get(“appname/wp\_postmeta”,filter\_data);

\_.each(REQUEST.response.record, function (record, index, list) {

Do stuff here

});

But unfortunately no go. I am a bit of a noob unfortunately.

Any hints would be great. Thanks.

Jason.

---

<div class="post-metadata">

**Author:** ![Jason\_Whalan](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@Jason\_Whalan](https://community.dreamfactory.com/u/Jason_Whalan)\
**Post date:** [February 19, 2016, 8:06am UTC](https://community.dreamfactory.com/t/documentation-and-examples-on-server-side-scripting/66/9 "2016-02-19T08:06:16Z")

</div>

Ok thanks guys I solved this eventually.

```
if (event.response.record) {
    _.each(event.response.record, function (record, index, list) {
        _.each(record.wp_postmetas_by_post_id, function (record, index, list) {
        
            if (record.meta_key == "_end_ts"){
                record.endseconds = record.meta_value;
            }
            if (record.meta_key == "_start_ts"){
                record.startseconds = record.meta_value;
            }
        });    
    });
}

```

Jason.
