Implemented db.search() almost completely