Fix getDocument() for views that emit values

A view could e.g. emit a scalar or an object with other data (e.g. `emit("mykey", 1);`) – still `getDocument()` should return the associated document.