Upsert condition with val() of a reverse edge count does not take effect

Hi,
I want delete any tag which has no edge link to it. so I run the upsert query below, it response 200 and len(txn.pred)==0(means nothing changed).

upsert{
  query{
    v as var(func: type(Tag)){
      c as count(~tags)
    }
  }
  mutation @if(eq(val(c),0)){
    delete{
      uid(v) * * .
    }
  }
}

and my schema define as below

name: string @index(term,trigram) @upsert @lang .
tags: [uid] @reverse @count .

type Tag{
	name
}

type Person{
	name
	name@cn
	tags
}

Conditional Upsert doesn’t support val.

You should do something like

upsert{
  query{
    v as var(func: type(Tag)) @cascade {
      c as count(~tags)
    }
  B as q(func: uid(c)) @filter(eq(val(c),0))
  }
  mutation @if(eq(len(B), 0) ){
    delete{
      uid(v) * * .
    }
  }
}

thanks for remind, I done the work by this

upsert{
  query{
    v as q1(func: type(Tag)) @cascade {
      c as count(~tags)
    }
    b as q2(func: uid(v)) @filter(eq(val(c),0))
  }
  mutation{
    delete{
      uid(b) * * .
    }
  }
}

Did it work? It should, I haven’t tested that specific case.

yes its worked , but function b in query is already filtered, so use it directly and no need to add Cond in mutation