编程技术网

关注微信公众号,定时推送前沿、专业、深度的编程技术资料。

 找回密码
 立即注册

QQ登录

只需一步,快速开始

极客时间

查询“不在".在Couchbase中:Querying "Not In" in Couchbase

ZRSlayee hbase 2022-5-10 14:59 5人围观

腾讯云服务器
查询“不在".在Couchbase中的处理方法

我在Couchbase中有一组文档,每个文档中可能都有一些用户作为编辑者-数组中有一组UserID.

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

Id是否要查询所有文档,其中具有特定用户名(用户名)的用户在编辑列表中不是?

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

这是我的数据:

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

关于上面的数据-我如何查询id为5的用户未在编辑器数组中列出的document类型的所有文档-意味着只应返回document1?

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

问题解答

好,我得到了一个适合我要求的解决方案.我在页面上添加了分页功能,这有助于避免浪费过多的资源.

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.

基本上,我每个周期返回文档"类型的100个文档(取决于页面大小).在每个周期中,我浏览行列表,然后仅选择未分配用户登录名的那些行.如果我的页面有100行,则返回,否则,我将进行另一个循环(页面大小),并尝试添加缺少的行以返回视图.

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.

发现另一件事-Telerik的LINQ to Couchbase

Another thing was found - LINQ to Couchbase by Telerik

这篇关于查询“不在".在Couchbase中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程技术网(www.editcode.net)!

腾讯云服务器 阿里云服务器
关注微信
^