如何在 Rethinkdb 中一次提取多个查询 [英] How to extract multiple queries at once in Rethinkdb
本文介绍了如何在 Rethinkdb 中一次提取多个查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想做类似的事情:
<代码>var tab = r.db("test").table("test");所有 =[tab.getAll('1').fitler({'hidden': false}).limit(1),tab.getAll('2').fitler('hidden': false}).limit(1),tab.getAll('3').fitler('hidden': false}).limit(1),]
但是在运行这个查询时我得到:
But when running this query I'm getting:
Expected type DATUM but found SELECTION:
推荐答案
一般情况下,Expected type DATUM but found SELECTION"错误可以通过添加.coerceTo('array')
来解决:
In general, the "Expected type DATUM but found SELECTION" error can be solved by adding .coerceTo('array')
:
var tab = r.db("test").table("test");
all =[
tab.getAll('1').filter({'hidden': false}).limit(1).coerceTo('array'),
tab.getAll('2').filter({'hidden': false}).limit(1).coerceTo('array'),
tab.getAll('3').filter({'hidden': false}).limit(1).coerceTo('array')
]
但在这种特定情况下,您可以将 .limit(1)
替换为 .nth(0)
:
But in this specific case, you can replace .limit(1)
with .nth(0)
:
var tab = r.db("test").table("test");
all =[
tab.getAll('1').filter({'hidden': false}).nth(0),
tab.getAll('2').filter({'hidden': false}).nth(0),
tab.getAll('3').filter({'hidden': false}).nth(0)
]
这篇关于如何在 Rethinkdb 中一次提取多个查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文