V8 field level security

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsV8 field level security

Count usage of a particular service, saving history in a database table. Each time a GET call is made on an API endpoint, write the transaction details to a 'TransactionHistory' table. Record the username, application key, and timestamp.

<source lang="javascript"> // Always remove some fields depending on the current role. API call returns 'social_security_number' and 'date_of_birth' from the database. Before returning JSON content to the client, remove tax_identifier and date_of_birth.

// get.post_process

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

lodash._.each(event.response.content.resource, function (record) {

   if (record.tax_identifier) {
       delete record.tax_identifier;
   }
   
   if (record.date_of_birth) {
       delete record.date_of_birth;
   }

}); </source>