Search code examples
couchbasecouchbase-view

Querying "Not In" in Couchbase


I have a set of documents in Couchbase where each may have some users as editors - a set of UserID`s in array.

Id like to query all the docs where user with particular userid (username) is not in list of editors?

here's what my data looks like:

document1: {editors[1,2,3,4]}
document2: {editors[1,2,3,4,5]}

user{id:5}

Regarding the data above - how can I query all the docs of type document where user with id=5 is not listed in editors array - meaning only document1 should return?


Solution

  • Ok, i got one solution that suits my requirements. I have added a paging functionality to the page, which helped to not waste too much resources.

    Basically i return 100 (depends on page size) docs per cycle of type "document". On each cycle i go through list of rows and select only those logged in user is not assigned to. In case i have 100 rows for a page i return then, otherwise i go on another cycle (page sized) and try to add missing rows to be returned for a view.

    This is quite ugly, but i cant see any easy and light to go solution without queries.

    Another thing was found - LINQ to Couchbase by Telerik