Deleting Data Continued
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.
[
{
"_id": ["person/handle", "jdoe"],
"handle": null
}
]
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:
[
{
"_id": ["person/handle", "jdoe"],
"favNums": [98],
"_action": "delete"
}
]
To delete all of ["person/handle", "jdoe"]
's favorite numbers, we would issue:
[
{
"_id": ["person/handle", "jdoe"],
"favNums": null
}
]
Cascading Deletes
If a subject has a predicate of with _predicate/type
of ref
, and _predicate/component
true
, deleting that subject will delete all of the referenced components. This only works in one direction, from the subject with the component predicate to the referenced subject, it does not work in reverse.
Delete a Favorite Number
Write a transaction!
Using the above transaction examples, write a transaction to delete just the number, 34, from `["person/handle", "dLopez"]`'s favorite numbers.