(private) Extract the value from a database response
@param {Array} res A database response array
@return {*}
10096
function extractResponseVal(res) {
        if (_u.isArray(res) && res.length && _u.isObject(res[0])) {
            var resObj = _u.values(res[0]);

            if (resObj.length) {
                return resObj[0];
            }
        }
    }
875906
function get(key) {
  const dataProp = 'data';

  return baseQuery(key)
    .select(dataProp)
    .where('id', key)
    .then(pullValFromRows(key, dataProp));
}
440603
function extractError(response, request) {

	var result,
	    entry,
	    req,
	    i;

	response = Blast.Bound.Array.cast(response);
	request = Blast.Bound.Array.cast(request);

	for (i = 0; i < response.length; i++) {
		entry = response[i];

		if (entry.error) {
			req = request[i] || {};
			result = new Error('Error in "' + req.type + '" command: ' + entry.error);
			result.type = req.type;
			result.vbmsg = entry.error;
			result.req = req;
			break;
		}
	}

	if (result) {
		result.original_response = response;
	}

	return result;
}
151681
function extractData(resp) {
    var req = resp.request;
    if (req.operation === 'getBucketLocation') {
      var match = resp.httpResponse.body.toString().match(/>(.+)<\/Location/);
      delete resp.data['_'];
      if (match) {
        resp.data.LocationConstraint = match[1];
      } else {
        resp.data.LocationConstraint = '';
      }
    }
    var bucket = req.params.Bucket || null;
    if (req.operation === 'deleteBucket' && typeof bucket === 'string' && !resp.error) {
      req.service.clearBucketRegionCache(bucket);
    } else {
      var headers = resp.httpResponse.headers || {};
      var region = headers['x-amz-bucket-region'] || null;
      if (!region && req.operation === 'createBucket' && !resp.error) {
        var createBucketConfiguration = req.params.CreateBucketConfiguration;
        if (!createBucketConfiguration) {
          region = 'us-east-1';
        } else if (createBucketConfiguration.LocationConstraint === 'EU') {
          region = 'eu-west-1';
        } else {
          region = createBucketConfiguration.LocationConstraint;
        }
      }
      if (region) {
          if (bucket && region !== req.service.bucketRegionCache[bucket]) {
            req.service.bucketRegionCache[bucket] = region;
          }
      }
    }
    req.service.extractRequestIds(resp);
  }
898398
private function cleanResponse( $res ) {

		$response_string = $res;
		// this is coming from API
		if( method_exists($res,'getBody') )
			$response_string = (string)$res->getBody();

		$response  = json_decode($response_string);

		return $response;
	}
975019
function extractRequestIds(resp) {
    var extendedRequestId = resp.httpResponse.headers ? resp.httpResponse.headers['x-amz-id-2'] : null;
    var cfId = resp.httpResponse.headers ? resp.httpResponse.headers['x-amz-cf-id'] : null;
    resp.extendedRequestId = extendedRequestId;
    resp.cfId = cfId;

    if (resp.error) {
      resp.error.requestId = resp.requestId || null;
      resp.error.extendedRequestId = extendedRequestId;
      resp.error.cfId = cfId;
    }
  }
1327059
function extractValues(response) {
    var observationData =
      response.GetObservationResponse &&
      response.GetObservationResponse.observationData;
    if (defined(observationData)) {
      if (!Array.isArray(observationData)) {
        observationData = [observationData];
      }
      var observations = observationData.map(o => o.OM_Observation);
      observations.forEach(observation => {
        if (!defined(observation)) {
          return;
        }
        var points = observation.result.MeasurementTimeseries.point;
        if (!defined(points)) {
          return;
        }
        if (!Array.isArray(points)) {
          points = [points];
        }
        var measurements = points.map(point => point.MeasurementTVP); // TVP = Time value pairs, I think.
        // var procedureTitle = defined(observation.procedure) ? observation.procedure['xlink:title'] : 'value';
        // var featureName = observation.featureOfInterest['xlink:title'];
        var featureIdentifier = observation.featureOfInterest["xlink:href"];
        dateValues.push(
          ...measurements.map(measurement =>
            typeof measurement.time === "object" ? null : measurement.time
          )
        );
        valueValues.push(
          ...measurements.map(measurement =>
            typeof measurement.value === "object"
              ? null
              : parseFloat(measurement.value)
          )
        );
        // These 5 arrays constitute columns in the table, some of which (like this one) have the same
        // value in each row.
        featureValues.push(...measurements.map(_ => featureIdentifier));
        procedureValues.push(...measurements.map(_ => procedure.identifier));
        observedPropertyValues.push(
          ...measurements.map(_ => observableProperty.identifier)
        );
      });
    }
  }
1281892
def get(self, res, cls, default = None):
        

        try:
            return self[(res, cls)]
        except KeyError:
            return default
1013323
function execute(req, res) {
  var value = req.db.getKey(req.args[0], req);
  if(value === undefined) return res.send(null, null);
  var buf = dump(
    {value: value}, value.rtype || Constants.TYPE_NAMES.STRING, null);
  res.send(null, buf);
}
1105265
function (req, res) {
	if (req.body) {
		//console.log(req.body.constructor)
		if (req.body.constructor !== Object) {return res.send({error:"Invalid Request body - should be Object"})};
	}
	var table = req.params["0"];
	var rcfg  = process.rapidcfg;
        var rmethod = req.method
	var extname = ""
	/* code for database distribution here ! */
	function GetUserDistName(lcstring){ return utils.hash(lcstring,1).toLowerCase()}		
	/* end */
	/* code for REDIS distribution here ! */
	function GetUserDistCache(lcstring){ return utils.hash(lcstring,1).toLowerCase()}		
	/* end */ 
	// check for table
	var accepted_list = rcfg.mdb.tables.names.slice(0);;
	accepted_list.push('up_data');
	accepted_list.push('up_tdata');
	accepted_list.push('rpdquery');
	if (utils.findin(accepted_list,table)){
		var primary_key = rcfg.mdb.tables.keys[table]
		if(!primary_key){
			if (table!='up_data' && table!='up_tdata' && table!='rpdquery'){
			return res.send({error:"Table - "+table+" - primary key not found in database!"})};
		} else {
		var dbcon = {};
		var rediscon = {};
		var base_db = rcfg.mdb.tables.db[table];
		if (rcfg.distributeddata == 1 && rcfg.mdb.databases[base_db].distributeddata==1){
			//extname = GetUserDistName(req.session.username.toLowerCase());
			//var dist_db = base_db +'_'+extname;
			//console.log(rcfg.mdb.databases[base_db].distributeddata)
			//req.session.username
			var dist_db = dbs.getdbdist(base_db,req.token.user);
			dbcon = rcfg.mdb.connections[dist_db];
			dbcon.rapiddb = dist_db
		} else {dbcon = rcfg.mdb.databases[base_db];dbcon.rapiddb = base_db};
		//console.log(dbcon);
		if (rcfg.distributedcache == 1){
			//req.session.username
			redisname = GetUserDistCache(req.token.user.toLowerCase());
			//console.log(redisname);
			rediscon  = rcfg.mdb.redis[redisname];
		};
		//console.log(rediscon);
		var table_structure = rcfg.mdb.tables.structures[table] }
		function rdbcallback(error,message){
			//console.log('Callback:');
			if (error){
				if(error){console.log(error)};
				//console.log(typeof(error.error));
				//console.log(Object.keys(error.error).length);
				res.status(400);
				return res.send(error)} 
			else {
				//console.log(message);
				return res.send(message)}
			};
		function rapidfind(){
			if (table == 'rpdquery'){
				rdb.runsql(req,rdbcallback);
			} else {
				if (req.query[primary_key]){
					rdb.find(req,table,primary_key,table_structure,dbcon,rediscon,rdbcallback);
				} else {
				//res.status(400);return res.send({error:'Query error/Primary key not found in GET:Query parameters'})
				rdb.find(req,table,false,table_structure,dbcon,rediscon,rdbcallback);
				}
			}
		};
		function rapidcreate(){
			if (req.body){
				function defaultcreate(){rdb.create(req,table,primary_key,table_structure,dbcon,rediscon,rdbcallback)}
				function up_data(){rdb.dataset(req,false,rdbcallback)}
				function up_tdata(){rdb.dataset(req,true,rdbcallback)}
				switch (table) {
				case 'up_tdata':
					if (rcfg.mdb.tables.structures[table]){
					if (Object.keys(req.body).length > 1){
						defaultcreate();
					}else {up_tdata}} else {
					up_tdata()};
					break;
				case 'up_data':
					if (rcfg.mdb.tables.structures[table]){
					if (Object.keys(req.body).length > 1){
						defaultcreate();
					}else {up_data()}} else {
					up_data()};
					break;
				default: defaultcreate()};
			} else {res.status(400);return res.send({error:'Query error/No parameters found-POST:Body/required format JSON'})}
		};
		function rapidupdate(){
			if (req.body[primary_key]){
				rdb.update(req,table,primary_key,table_structure,dbcon,rediscon,rdbcallback)
			} else {res.status(400);return res.send({error:'Query error/Primary key not found in PUT:Body parameters'})}
		};
		function rapiddelete(){
			var key_value = false
			var key_value = req.query[primary_key]
			if (!key_value){key_value = req.body[primary_key]}
			if (key_value){
				rdb.destroy(req,table,primary_key,table_structure,dbcon,key_value,rediscon,rdbcallback)
			} else {res.status(400);return res.send({error:'Query error/Primary key not found in DELETE:Query parameters'})}
		};
		switch (rmethod) {
	    	case 'GET':rapidfind();break;
	    	case 'POST':rapidcreate();break;
		case 'PUT':rapidupdate();break;
		case 'DELETE':rapiddelete();break;
	    	default:
			return res.send({error:"Method - "+req.method+" - not alowed!"});
		} 
	} else { return res.send({error:"Table - "+ table+" - not found!"})}; // code for waterline redirect here !
  }
581890
function(res) {
    res.setEncoding('utf8');
    var data = "";
    res.on('data', function(chunk) {
      data+=chunk;
    });

    res.on('end', function() {
      // Get HTTP Statuscode and act according to situation
      var code = res.statusCode;
      try { // try to parse JSON
        var answer = JSON.parse(data);
      } catch (e) {
        var err = {};
        err.http_code = 500;
        err.message = "No valid JSON received: "+data;
        callback(err, null);
        return;
      }
      if(code >= 200 && code <= 206) { // request was successful
        callback(null, answer);
      } else if (code >= 300 && code <= 307) { // server send redirect
        // we do not follow anything the server wants us to follow right now, since this should never be the case.
        // instead let's raise an error.
        var err = new Object();
        err.http_code = 500;
        err.message = "Redirects not supported by pastyclient-node"
        callback(err, null);
      } else if (code >= 400 && code <= 418) { // client error
        if(typeof(answer.error) == "object") {
          var err = answer.error;
        } else if(answer.code != undefined && answer.message != undefined) { // New RestError, temporary support both 
          var err = answer;
          err.http_code = code;
        } else {
          var err = new Object();
          err.http_code = code;
          err.message = "Resource not found";
        }
        callback(err, null);
      } else if (code >= 500 && code <= 505) { // server error
        if(typeof(answer.error) == "object") {
          var err = answer.error;
        } else {
          var err = new Object();
          err.http_code = code;
          err.message = "Internal Server Error";
        }
        callback(err, null);
      } else {
        // Not existant HTTP code. Raise error.
        var err = new Object();
        err.http_code = 500;
        err.message = "HTTP Status Code "+code+" is not supported by pastyclient-node"
        callback(err, null);
      }
    });
  }
614493
function getValue(fromObject, fromKey) {
  var regDot = /\./g
    , regFinishArray = /.+(\[\])/g
    , keys
    , key
    , result
    , lastValue
    ;

  keys = fromKey.split(regDot);
  key = keys.splice(0, 1);

  result = _getValue(fromObject, key[0], keys);

  return handleArrayOfUndefined_(result);
}
764403
static public function openResult($res) {
		if (!is_array($res))
			throw new Exception('Invalid datatype. Array expected!');

		if (isset($res['error']))
			throw new Exception('Server error: '.$res['error']);

		if (!isset($res['result']))
			throw new Exception('Server returned no result.');

		return $res['result'];
	}
1193671
function formatResponse (res) {
    // iterate over rows in response
    _.each(res, row => {
        // iterate over key/value pairs in row object
        _.each(row, (val, key) => {
            // convert nulls to undefined
            if (val === null) {
                row[key] = undefined
            }
        })
    })
}
1168836
function(req, res) {
            var updateJson = {};
            var updateSelector = {};

            //Request database structure
            lastQry = connection.query('SHOW COLUMNS FROM ??', req.params.table , function (err, columns) {
                if (err) return sendError(res,err.code);

                //Check if the request is provided an select value
                if (typeof req.params.id === "undefined") {
                    return sendError(res,'Please specify an selector value for the fields ');
                } else {
                    updateSelector.value = req.params.id;
                    updateSelector.field = findPrim(columns,req.query[settings.paramPrefix + 'field']);
                }

                //If the user only wants to update files
                if( Object.keys(req.body).length == 0) {
                    req.body = req.files;
                }
                var value;
                var iterator = function (i) {
                    if (i >= columns.length || (typeof req.body.length === "undefined" && typeof req.files.length !== "undefined")) {
                        if(JSON.stringify(updateJson) !== '{}') {
                            updateIntoDB();
                        } else {
                            return sendError(res,'No Data received!');
                        }
                        return;
                    }
                    var dbField = columns[i];
                    var field = dbField.Field;
                    //Check if the current checked field is set
                    if(typeof req.body[field] !== "undefined" || (dbField.Default == 'FILE' && typeof req.files[field] !== "undefined") ) {
                        //First check if the field is required
                        if(dbField.Null == 'NO' && dbField.Extra != 'auto_increment') {
                            value = checkIfSentvaluesAreSufficient(req,dbField);
                            if(value !== false) {
                                updateJson[field] = value;
                                iterator(i + 1);
                            } else {
                                return sendError(res,"Not all 'NOT NULL' fields are filled ("+ field +" is missing)");
                            }
                        }  else {
                            //Check for not required fields
                            //Skip auto_incremented fields
                            if(dbField.Extra === 'auto_increment') {
                                iterator(i + 1);
                            } else {
                                //Check if the field was provided by the client
                                var defined = false;
                                if(dbField.Default == "FILE") {
                                    if(req.files.hasOwnProperty(dbField.Field)) {
                                        defined = true;
                                    }
                                } else {
                                    if(typeof req.body[field] !== "undefined") {
                                        defined = true;
                                    }
                                }

                                //If it was provided, check if the values are okay
                                if(defined) {
                                    value = checkIfSentvaluesAreSufficient(req,dbField);
                                    if(value !== false) {
                                        updateJson[field] = value;
                                        iterator(i + 1);
                                    } else {
                                        if(dbField.Default == "FILE") {
                                            return sendError(res, 'Value for field ' + field + ' is not sufficient. Either the file is to large or an other error occured');
                                        } else {
                                            return sendError(res, 'Value for field ' + field + ' is not sufficient. Expecting ' + dbField.Type + ' but got ' + typeof req.body[field]);
                                        }
                                    }
                                } else {
                                    //If not, don't mind
                                    iterator(i + 1);
                                }
                            }
                        }
                    } else {
                        iterator(i + 1);
                    }
                };

                iterator(0); //start the async "for" loop

                function updateIntoDB() {
                    //Yaaay, alle Tests bestanden gogo, insert!
                    lastQry = connection.query('UPDATE ?? SET ? WHERE ?? = ?', [req.params.table , updateJson, updateSelector.field, updateSelector.value] , function (err) {
                        if (err) return sendError(res,err.code);
                        sendSuccessAnswer(req.params.table , res, req.params.id, updateSelector.field);

                    });
                }
            });
        }
1197669
def result(self, res):
        ''''''
        return self >> Parser(lambda _, index: Value.success(index, res))
1224906
function(res, method, model, options) {
		// parse non-document responses
		if (res._id == null && res._rev == null) {
			// write result
			if (method !== "read") return { _id: res.id, _rev: res.rev };

			// view result
			if (res.rows != null) {
				if (isCollection(model)) return res.rows.map(function(row) {
					return row[options.rowKey];
				});

				// grab just the first row for models
				return res.rows.length ? res.rows[0][options.rowKey] : null;
			}

			// changes feed result
			if (res[options.rowKey] != null) return res[options.rowKey];
		}

		return res;
	}