moved doc manipulation under db, more nano like