share/livedb — pull request #11 by geigerzaehler (2013-10-21 18:16:07+00:00)
Title: Update queries when documents deleted

First commit is to test behavior. This should definitely be tested without stubbing. But it does not work this way. The problem is, that in the `Livedb.query` method a document is only removed from a query if the query does not contain the document (see code for [polling](https://github.com/share/livedb/blob/master/lib/index.js#L1040) and [non-polling](https://github.com/share/livedb/blob/master/lib/index.js#L1088)). But the query methods for the memory db return a document without type and data. This is because the delete operation does not delete the document but unsets type and data. The second commit changes the behavior of the query methods to treat documents without data as non-existent/deleted.

Currently the mongo adapter behaves as the memory db before. This breaks the query mechanism for deletes! The whole situation raises the question what the semantics of a document without type and data is and how to represent non-existent document. I suspect this ambiguity is producing more undiscovered bugs.