move much records db logic to db.js from index.js
type now refers to sectionName almost everywhere