Couchbase N1QL:在阵列上直接使用select
我在查询数组中的对象时遇到问题 我有这个样本文件Couchbase N1QL:在阵列上直接使用select,couchbase,n1ql,Couchbase,N1ql,我在查询数组中的对象时遇到问题 我有这个样本文件 { ... status: 'active', current: { ... }, history: [ { id: '73bae187-1101-4fb3-a71a-2bbf90026eb3', date: '2017-03-28T09:32:22.884Z', content: 'This is second content' }, { id: 'd6a6
{
...
status: 'active',
current: { ... },
history: [
{
id: '73bae187-1101-4fb3-a71a-2bbf90026eb3',
date: '2017-03-28T09:32:22.884Z',
content: 'This is second content'
},
{
id: 'd6a6c63d-42db-4ef5-88e9-616cfe539a57',
date: '2017-03-25T09:32:22.884Z',
content: 'This is first content'
},
{
id: '3fbdb846-2b55-4ff8-8960-86997ef31556',
schedule: '1970-01-01T00:00:00.000Z',
content: 'This is a very old content'
}
]
}
我想直接从要应用日期过滤器的历史数组子文档中进行查询
在n1ql中是否可以检索仅包含满足条件的对象的历史数组
我可以应用一个限制来控制数组中返回对象的数量吗
我尝试了一些使用拼接[0:$1]的查询,其中limit是一个输入,但在limit大于数组大小时不起作用
谢谢您的帮助。尝试以下方法之一:
SELECT h[0:least(ARRAY_LENGTH(h), $arraylimit)] As h FROM default As d
LET h = ARRAY v FOR v IN d.history WHEN v.id IN [ 'xyz', 'pqr'] END;
或:
请尝试以下方法之一:
SELECT h[0:least(ARRAY_LENGTH(h), $arraylimit)] As h FROM default As d
LET h = ARRAY v FOR v IN d.history WHEN v.id IN [ 'xyz', 'pqr'] END;
或:
我想知道是否有人也可以用解释来编辑此内容:我想知道是否有人也可以用解释来编辑此内容: