Update db.js

fix query and create more tables