Hi @teja,
This can be achieved using upserts. Consider the following example.
{
set {
_:a <name> "alice" .
_:a <country> "japan" .
}
}
suppose you want to change the country of Alice, you can do this by:
upsert{
query {
q(func: eq(name, "alice")) {
v as uid
name
}
}
mutation {
set {
uid(v) <country> "India" .
}
}
}
I want to change the predicate name to differentiate the type data then how can I acheive that ??
Now if you want to change the name of predicate itself, for example changing the name of predicate “name” to “first_name” by:
upsert{
query {
q(func: has(name)) {
v as uid
n as name
}
}
mutation {
set {
uid(v) <first_name> val(n) .
}
delete{
uid(v) <name> * .
}
}
}
I want to update a node with a new field or to remove an existing field how can I achieve that
Quite similar, the below example adds new predicate age, in the node with name equal to alice.
upsert{
query {
q(func: eq(name, "alice")) {
v as uid
name
}
}
mutation {
set {
uid(v) <age> "21" .
}
}
}