don't return deleted docs by checking for type and properly handle queries with an _id