[英]ArangoDB: Use an objects as a filter and build AQL with aql builder
I have an objectlike this 我有一个这样的对象
{
prop1: true,
prop2: "string",
prop3: number
}
I give this object to Foxx in order to use its properties as filters for arango query. 我将此对象提供给Foxx,以便将其属性用作arango查询的过滤器。 I use an query builder as of the following
我从以下开始使用查询构建器
var qb = require('aqb');
var querybuilder=qb.for("doc").in(docCollection);
//Loop through the object property
for(var property in object){
if (object.hasOwnProperty(property)){
var value= object[property];
var key="doc."+property;
querybuilder=querybuilder.filter(qb.eq(key,value));
}
}
But this one wont work because qb.eq(key,value)
is not accepted qb.eq(key,qb.str(value))
then it is okay but the filter now filters only against string type value. 但是这一次不会工作,因为
qb.eq(key,value)
不接受qb.eq(key,qb.str(value))
那么它是好的,但过滤现在仅过滤对字符串类型的值。
How can I build an query that filter using the exact type of value in filter object? 如何建立使用过滤器对象中值的确切类型进行过滤的查询?
God, I solved this literraly 3 seconds after posting. 天哪,我在发布3秒钟后就解决了这个问题。 All I have to do is to do any conversion like this
我要做的就是做这样的转换
qb.eq(key,qb(value))
And arango does the rest. 而arango负责其余的工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.