api/users.js
/**
* Provides all required query for users resource
*/
Provides all required query for users resource
Provides all required query for users resource
function queryMaker() {
    return {
        fetchUsers: "Select * from user",
        fetchOneUser : function (id){
            return "Select * from user where userId = " + id;
        },
        createUser : function (data){
            return "Insert into user(firstName, lastName, balance, isFoysteamer, promo) values ("
                + '"' + data.firstName + '", '
                + '"' + data.lastName + '", '
                + '"' + data.balance + '", '
                + '"' + data.isFoysteamer + '", '
                + '"' + data.promo + '")';
        },
        deleteUser : function (id){
            return "Delete from user where userId = " + id;
        },
        updateUser : function(id, data){
            return "update user "
                + 'set firstName = "' + data.firstName + '", '
                + 'lastName = "' + data.lastName + '", '
                +  'promo = "' + data.promotion + '", '
                +  'isFoysteamer = ' + data.isFoysteamer + ', '
                +  'balance = ' + data.balance + ' '
                + 'where userId = ' + id;
        }
    }
}
function queryMaker ( ) { return { fetchUsers : "Select * from user" , fetchOneUser : function ( id ) { return "Select * from user where userId = " + id ; } , createUser : function ( data ) { return "Insert into user(firstName, lastName, balance, isFoysteamer, promo) values (" + '"' + data . firstName + '", ' + '"' + data . lastName + '", ' + '"' + data . balance + '", ' + '"' + data . isFoysteamer + '", ' + '"' + data . promo + '")' ; } , deleteUser : function ( id ) { return "Delete from user where userId = " + id ; } , updateUser : function ( id , data ) { return "update user " + 'set firstName = "' + data . firstName + '", ' + 'lastName = "' + data . lastName + '", ' + 'promo = "' + data . promotion + '", ' + 'isFoysteamer = ' + data . isFoysteamer + ', ' + 'balance = ' + data . balance + ' ' + 'where userId = ' + id ; } } }
Provides all required query for users resource
Provides all required query for users resource