0

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. 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.

How can I build an query that filter using the exact type of value in filter object?

Loredra L
  • 1,485
  • 2
  • 16
  • 32

1 Answers1

0

God, I solved this literraly 3 seconds after posting. All I have to do is to do any conversion like this

qb.eq(key,qb(value))

And arango does the rest.

Loredra L
  • 1,485
  • 2
  • 16
  • 32
  • 2
    Please keep in mind that the aql builder is not maintained anymore and ArangoDB does not recommend using this lib anymore. Take a look into the docs for the alterative aql template handler https://docs.arangodb.com/3.4/Manual/Foxx/Guides/Queries.html – mpv89 Sep 18 '18 at 07:22