/* GET THE ROUTE ID BASED ON THE ROUTE (METHOD + PATH) */
/* =============================================================================================================== */
DROP FUNCTION IF EXISTS GET_ROUTE_ID;
COMMIT;

DELIMITER //

CREATE FUNCTION `GET_ROUTE_ID`(`p_route` varchar(255))
RETURNS INTEGER
DETERMINISTIC
BEGIN

	DECLARE routeId INTEGER DEFAULT NULL;
	
	SET routeId = (
    SELECT `_id`
    FROM `Routes`
    WHERE CONCAT(`method`, ' ', `path`) = p_route
  );
	
	RETURN routeId;

END 
//
COMMIT //

DELIMITER ;
