Compare values in 2 predicates

I was trying to compare values in two predicates of the same node. Is there way of doing it? All the samples show the 2nd parameter as a constant and not a predicate.

NB:- Since this is a doubt in DQL, i selected the category as “Users”.

1 Like

Pretty sure this is not possible, but it could be useful. A simple use case would be financial, ie: a node has a predicate for the max value and a value that gets incremented and the query needs to find all nodes that their incremental values are at their max value. This might be more useful with auth on predicates to protect certain predicates.

Couldn’t this be done with a val() variable?

J

Maybe something like:

{
  var(func: type(Account)) {
    t as balanceThreshhold
  }
  alertAccounts(func: lt(balance, val(t)) @filter(type(Account)) {
    uid
    balanceThreshhold
    balance
  }
}

I did not test this, just an idea

The problem with this query is that if you have multiple Account nodes and you want all that have balance < threshold.
The error is:
": lt expects only 1 argument. Got: []",

It would be a very useful feature to be able to compare two predicates.

1 Like