extracted database code to a dbal.js module