Partial port of db.scm to new method