gpt4 book ai didi

java - 在 Rethink db 中,我如何在以下场景中检索键值对?

转载 作者:太空宇宙 更新时间:2023-11-04 10:10:30 25 4
gpt4 key购买 nike

{
"id" :"Reserved"
"1" :"Free"
"2" :"Free"
"3" :"Reserve"
.
.
"100":"Free"
}

我使用了这个查询:

r.db(DBName).table(tableName).get(docId).values().contains(regex).run(conn);

这里:使用正则表达式免费

这为我提供了所有免费的值,但我想获取正则表达式为免费或保留的(键,值)对。

我可以通过任何方式检索免费的键值对的数量吗?:

 "1" :"Free"
"2" :"Free"
"100":"Free"

安装了

"Free"
"Free"
"Free"

最佳答案

你可以试试这个

r.db("DB").table("TABLENAME").get("DOC_ID").do(function(doc){
return doc.keys().filter(function(value){
return doc(value).match("Free")
}).map(function(key){
return r.object(key,doc(key))
})
})

基本上,您需要过滤相应值为“Free”的所有键。然后返回key和value

关于java - 在 Rethink db 中,我如何在以下场景中检索键值对?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52407859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com