CouchDB equivalent of Sql NOT IN?

前端 未结 3 1267
故里飘歌
故里飘歌 2021-01-05 05:35

I\'m looking for the CouchDB JS view equivalent of the following LinQ query :

    var query =
        from f in context.Feed
        where !(from ds in conte         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-05 06:28

    I know this is an old post, but having been confronted with the same problem I think that Marcin's answer is correct but incomplete.

    In my case I used the following list function to select get all rows except the ones with a certain excludeId:

    function(head, req) {
    start({ 'headers': { 'Content-Type': 'application/json' } });
     var rows = [];
     while (row = getRow()) {
        if (!req.query.exceptId || doc.documentId != req.query.exceptId) {
            rows.push(row);
        }
     }
     send(JSON.stringify({ total_rows: rows.length, rows: rows }));
    }
    

    you can read more here

提交回复
热议问题