Quantcast
Channel: DreamFactory Forum - Latest posts
Viewing all articles
Browse latest Browse all 5028

How to assign the current user id to post api in dreamfactory?

$
0
0

Hi,

I suppose it can be done with event scripts pre-process http://wiki.dreamfactory.com/DreamFactory/Tutorials#Scripting

// POST /api/v2/treat_well/_table/tw_venue triggers script treat_well._table.tw_venue.post.pre_process
// This script runs BEFORE records are written to the db.
// records are in array event.request.payload.resource.

var lodash = require("lodash.min.js");

if (event.request.payload.resource) {
    lodash._.each(event.request.payload.resource, function( record ) {
        record.user_id: platform.session.user.id
    });
}

And maybe you can make things even simpler to use Data Mesh http://blog.dreamfactory.com/working-with-virtually-related-data-0


Viewing all articles
Browse latest Browse all 5028

Trending Articles