Delete
Delete( ref )
Delete( ref )
Delete( ref )
Delete( ref )
delete( ref )
delete ref
Delete( ref )
Delete( ref )
Description
The Delete
function removes an object. Some of the common objects to
delete are Documents, Collections, Indexes, and Databases.
When you delete a Collection that is the single source for an index, the index is also deleted.
For performance, Databases, Collections, Functions, Indexes,
Keys, and Roles use an object cache. When you use Delete to
delete any of these FaunaDB schema documents, the
deletion is not guaranteed to be visible immediately.
|
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
Reference |
The reference to an object that was removed. |
Returns
An object containing the metadata about the delete operations.
Field Name | Field Type | Definition and Requirements |
---|---|---|
|
String |
The logical name of an existing database. |
|
String |
The access roles include |
|
Object |
Optional - This is user-defined metadata for the key. It is provided for the developer to store information at the key level. |
|
Long |
Optional - A relative weight between 1 and 500, inclusive, indicating how many resources this database is allowed to utilize. Defaults to 1. A higher number means more resources. |
Examples
The query below removes the document pointed at by the reference.
curl https://db.fauna.com/ \
-u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
-d '{ "delete": { "@ref": "classes/spells/181388642581742080" } }'
client.Query(Delete(Ref(Collection("spells"), "181388642581742080")));
System.out.println(
client.query(
Delete(Ref(Collection("spells"), Value(181388642581742080L)))
).get());
result, _ := client.Query(
f.Delete(f.RefCollection(f.Collection("spells"), "181388642581742080")),
)
fmt.Println(result)
client.query(Delete(Ref(Collection("spells"), "181388642581742080")))
client.query(q.delete(q.ref(q.collection("spells"), "181388642581742080")))
$client.query do
delete ref('classes/spells/181388642581742080')
end
client.query(
Delete(ref: Ref(Collection("spells"), "181388642581742080"))
)
client.query(q.Delete(q.Ref(q.Collection('spells'), '181388642581742080')))
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{
"resource": {
"ref": { "@ref": "classes/spells/181388642581742080" },
"class": { "@ref": "classes/spells" },
"ts": 1509244539764856,
"data": {
"name": "Mountain's Thunder",
"element": [ "air", "earth" ],
"cost": 10
}
}
}
{
"ref": { "@ref": "classes/spells/181388642581742080" },
"class": { "@ref": "classes/spells" },
"ts": 1509244539764856,
"data": {
"name": "Mountain's Thunder",
"element": [ "air", "earth" ],
"cost": 10
}
}
{
ref: ref(id = "181388642581742080", collection = ref(id = "spells", collection = ref(id = "collections"))),
ts: 1509244539764856,
data: {
name: "Mountain's Thunder",
element: ["air", "earth"],
cost: 10
}
}
map[ref:{181388642581742080 0xc4201f3da0 <nil>} ts:1509244539764856 data:map[cost:10 element:[air earth] name:Mountain's Thunder]]
{
"ref": { "@ref": "classes/spells/181388642581742080" },
"class": { "@ref": "classes/spells" },
"ts": 1509244539764856,
"data": {
"name": "Mountain's Thunder",
"element": [ "air", "earth" ],
"cost": 10
}
}
{
"ref": { "@ref": "classes/spells/181388642581742080" },
"class": { "@ref": "classes/spells" },
"ts": 1509244539764856,
"data": {
"name": "Mountain's Thunder",
"element": [ "air", "earth" ],
"cost": 10
}
}
{
"ref": { "@ref": "classes/spells/181388642581742080" },
"class": { "@ref": "classes/spells" },
"ts": 1509244539764856,
"data": {
"name": "Mountain's Thunder",
"element": [ "air", "earth" ],
"cost": 10
}
}
{
"ref": { "@ref": "classes/spells/181388642581742080" },
"class": { "@ref": "classes/spells" },
"ts": 1509244539764856,
"data": {
"name": "Mountain's Thunder",
"element": [ "air", "earth" ],
"cost": 10
}
}
{ ref:
Ref(id=181388642581742080, collection=Ref(id=spells, collection=Ref(id=collections))),
ts: 1527275280180078,
data:
{ name: 'Mountain\'s Thunder',
element: [ 'air', 'earth' ],
cost: 10 } }
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!