I prepare to use CouchDB to my project. but cannot find a way to implement a view like an SQL SELECT * FROM Employees WHERE LastName NOT IN (SELECT LastName FROM Managers). In other words, I want to get a set from view A but not in view B. Question: how to implement not-in condition in CouchDB?
I prepare to use CouchDB to my project. but cannot find a way to
Share
Keeping employees and managers lists different sets of documents is using relational structure where you DB is not relational. If, for some reason, you are forced to do that, you need some way to distinguish the scheme of the doc (from which table it is). Lets say you are doing it with field
scheme:Then you can use map:
If, for some strange reason, you cannot do that, and you only have the reference to employee doc in manager doc, you can emit both documents:
You will get the list of employees with keys
["employee_id", 1], and each manager is preceded with the row labeled as manager (key[..., 0]). This will require some space, but with list function you can filter out managers easily and the client will receive from DB only the non-managers.Keep in mind, that it is only the workaround for not making proper DB design.