controllers/api.js
function findPrim(columns,field) {

    var primary_keys = columns.filter(function (r) {return r.Key === 'PRI';});

    //for multiple primary keys, just take the first
    if(primary_keys.length > 0) {
        return primary_keys[0].Field;
    }

    //If the provided field is a string, we might have a chance
    if(typeof field === "string") {
        if(checkIfFieldsExist(field,columns)) {
            return escape(field);
        }
    }

    //FALLBACK
    return "id";
}
function findPrim(columns,field) {

    var primary_keys = columns.filter(function (r) {return r.Key === 'PRI';});

    //for multiple primary keys, just take the first
    if(primary_keys.length > 0) {
        return primary_keys[0].Field;
    }

    //If the provided field is a string, we might have a chance
    if(typeof field === "string") {
        if(checkIfFieldsExist(field,columns)) {
            return escape(field);
        }
    }

    //FALLBACK
    return "id";
}
function findPrim ( columns , field ) { var primary_keys = columns . filter ( function ( r ) { return r . Key === 'PRI' ; } ) ; //for multiple primary keys, just take the first if ( primary_keys . length > 0 ) { return primary_keys [ 0 ] . Field ; } //If the provided field is a string, we might have a chance if ( typeof field === "string" ) { if ( checkIfFieldsExist ( field , columns ) ) { return escape ( field ) ; } } //FALLBACK return "id" ; }
Get primary key, or if specified
@param columns
@param field
@returns {*}
Get primary key or if specified