jdgamble555
(Jonathan Gamble)
1
I am wondering how to delete all nodes of type X in DQL using JSON format:
{
"delete": {
"dgraph.type": "Private",
"uid": "*",
}
}
I am looking for the equivalent of this:
upsert {
query {
d as var(func: eq(dgraph.type, "Private"))
}
mutation {
delete {
uid(d) * * .
}
}
}
Is this possible using JSON?
J
1 Like
MichelDiz
(Michel Diz)
2
Something like this(need to check if the “Private” quotes need escaping)
S * *
curl -H "Content-Type: application/json" -X POST localhost:8080/mutate?commitNow=true -d '{
"query": "{ d as var(func: eq(dgraph.type, "Private")) }",
"delete": {
"uid": "uid(d)"
}
}' | jq
S P *
curl -H "Content-Type: application/json" -X POST localhost:8080/mutate?commitNow=true -d '{
"query": "{ d as var(func: eq(dgraph.type, "Private")) }",
"delete": {
"uid": "uid(d)",
"myPredicate": "null",
}
}' | jq
2 Likes
jdgamble555
(Jonathan Gamble)
3
I tried this:
{
"query": "{ d as var(func: eq(dgraph.type, \"Private\")) }",
"delete": {
"uid": "uid(d)"
}
}
It says Message: Done
in ratel, but nothing was deleted.
J
MichelDiz
(Michel Diz)
4
jdgamble555
(Jonathan Gamble)
5
My schema was made in GraphQL.
type Private {
text: String
…
}
I’m trying to do S * *
J
amaster507
(Anthony Master)
6
Do you need the upsert keyword??
jdgamble555
(Jonathan Gamble)
7
It doesn’t look like they do in the example:
https://dgraph.io/docs/mutations/upsert-block/
But maybe the example was wrong?
I am thinking S * *
is not possible but S P *
is.
J
jdgamble555
(Jonathan Gamble)
8
Nm, got it to work. I took off the quotes in Private, and there was something wrong with ratel.
{
"query": "{ d as var(func: eq(dgraph.type, Private)) }",
"delete": {
"uid": "uid(d)"
}
}
J