controllers/api.js
function sendSuccessAnswer(table, res, id, field) {
    if(typeof field === "undefined") {
        if(id === 0) {
            //Just assume that everything went okay. It looks like a non numeric primary key.
            res.send({
                result: 'success',
                table: table
            });
            return;
        } else {
            field = "id";
        }
    }
    lastQry = connection.query('SELECT * FROM ?? WHERE ?? = ?', [table, field, id] , function (err, rows) {
        if (err) {
            sendError(res, err.code)
        } else {
            res.send({
                result: 'success',
                json: rows,
                table: table
            });
        }
    });
}
function sendSuccessAnswer(table, res, id, field) {
    if(typeof field === "undefined") {
        if(id === 0) {
            //Just assume that everything went okay. It looks like a non numeric primary key.
            res.send({
                result: 'success',
                table: table
            });
            return;
        } else {
            field = "id";
        }
    }
    lastQry = connection.query('SELECT * FROM ?? WHERE ?? = ?', [table, field, id] , function (err, rows) {
        if (err) {
            sendError(res, err.code)
        } else {
            res.send({
                result: 'success',
                json: rows,
                table: table
            });
        }
    });
}
function sendSuccessAnswer ( table , res , id , field ) { if ( typeof field === "undefined" ) { if ( id === 0 ) { //Just assume that everything went okay. It looks like a non numeric primary key. res . send ( { result : 'success' , table : table } ) ; return ; } else { field = "id" ; } } lastQry = connection . query ( 'SELECT * FROM ?? WHERE ?? = ?' , [ table , field , id ] , function ( err , rows ) { if ( err ) { sendError ( res , err . code ) } else { res . send ( { result : 'success' , json : rows , table : table } ) ; } } ) ; }
Send the edited element to the requester
@param table
@param res
@param id
@param field
Send the edited element to the requester