Oracle Magazine, September/October 2018
Database Developer OPEN SOURCE ORACLE MAGAZINE SEPTEMBER OCTOBER 2018 72 if context id binds employee_ id context id query nwhere employee_ id employee_ id const result await database simpleExecute query binds return result rows module exports find find The employees database module brings in the generic database module and then initializes a constant named baseQuery to a SQL query on the employees table Double quoted column aliases are used in the query to control the case of the keys returned Next a function named find is declared and used to execute the query and return the rows fetched If the context parameter passed in has a truthy value for id then a WHERE clause is appended to the query so that only a single employee is returned Note that the value of context id was not appended to the query directly Instead a placeholder named employee_ id was used this is known as a bind variable Using bind variables with Oracle Database is very important for security and performance reasons The value of the bind variable is assigned to the binds object which
You must have JavaScript enabled to view digital editions.