Deleting Data
Delete Subject
To delete/retract an entire subject, use the _id
key along with only "_action": "delete"
. This deletes (retracts) the subject and all predicates. In addition, all of the references for that subject anywhere in the ledger are also retracted.
- FlureeQL
- Curl
- GraphQL
- SPARQL
[
{
"_id": ["person/handle", "zsmith"],
"_action": "delete"
}
]
curl \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $FLUREE_TOKEN" \
-d '[{
"_id": ["person/handle", "zsmith"],
"_action": "delete"
}]' \
[HOST]/api/db/transact
mutation deleteAllPredicates ($myDeleteAllPredicatesTx: JSON) {
transact(tx: $myDeleteAllPredicatesTx)
}
{
"myDeleteAllPredicatesTx": "[{ \"_id\": [\"person/handle\", \"zsmith\"], \"_action\": \"delete\" }]"
}
Transactions not supported in SPARQL
Delete Specific Predicates
To delete only specific predicate-objects within an subject, specify the key/value combinations.
You can delete (retract) a single predicate by setting the value of _id
to a two-tuple of the predicate and predicate value, and then setting the predicate to null. "_action": "delete"
is inferred.
- FlureeQL
- Curl
- GraphQL
- SPARQL
[
{
"_id": ["person/handle", "jdoe"],
"age": null
}
]
curl \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $FLUREE_TOKEN" \
-d '[{
"_id": ["person/handle", "jdoe"],
"age": null
}]' \
[HOST]/api/db/transact
mutation deletePredicate ($myDeletePredicateTx: JSON) {
transact(tx: $myDeletePredicateTx)
}
{
"myDeletePredicateTx": "[{ \"_id\": [\"person/handle\", \"jdoe\"], \"age\": null }]"
}
Transactions not supported in SPARQL
Delete Specific Multi Predicates
To delete (retract) only a single object from a multi predicate, specify the predicate-object, and add "_action": "delete"
For example, to delete just the number, 98, from ["person/handle", "jdoe"]
's favorite numbers, we would issue:
- FlureeQL
- Curl
- GraphQL
- SPARQL
[
{
"_id": ["person/handle", "jdoe"],
"favNums": [98],
"_action": "delete"
}
]
curl \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $FLUREE_TOKEN" \
-d '[{
"_id": ["person/handle", "jdoe"],
"favNums": [98],
"_action": "delete"
}]' \
[HOST]/api/db/transact
mutation deletefavNum ($myDeleteFavNumTx: JSON) {
transact(tx: $myDeleteFavNumTx)
}
{
"myDeleteFavNumTx": "[{ \"_id\": [\"person/handle\", \"jdoe\"], \"favNum\": [98], \"_action\": \"delete\" }]"
}
Transactions not supported in SPARQL
To delete all of ["person/handle", "jdoe"]
's favorite numbers, we would issue:
- FlureeQL
- Curl
- GraphQL
- SPARQL
[
{
"_id": ["person/handle", "jdoe"],
"favNums": null
}
]
curl \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $FLUREE_TOKEN" \
-d '[{
"_id": ["person/handle", "jdoe"],
"favNums": null
}]' \
[HOST]/api/db/transact
mutation deletefavNums ($myFavNumsTx: JSON) {
transact(tx: $myFavNumsTx)
}
{
"myFavNumsTx": "[{ \"_id\": [\"person/handle\", \"jdoe\"], \"favNums\": null }]"
}
Transactions not supported in SPARQL