Remove

Remove(ref, ts, action)
Remove(ref, ts, action)
Remove(ref, ts, action)
Remove(ref, ts, action)
remove(ref, ts, action)
Remove(ref, ts, action)

Description

The Remove function deletes an event from a document’s history.

The ref parameter must be a reference to a document within a user-defined collection.

Since documents are stored immutably within Fauna, events are stored as snapshots of the associated document. Directly manipulating document history, using the Insert and Remove functions, does not currently affect subsequent event snapshots.

Parameters

Parameter Type Definition and Requirements

ref

A Reference to the document that should have an event removed.

ts

The timestamp for the specific entry in the document’s history that should be removed. Can be expressed as either a number of UNIX microseconds since the Unix epoch, or as a Timestamp.

For large values of ts (positive or negative), you may need to express the value in a String to maintain numeric precision (Fauna uses 64-bit signed integers, whereas JavaScript uses 53-bit signed integers).

action

The type of action (create, delete, update) to be removed.

Returns

An object containing the metadata of the remove operations.

Field Name Field Type Definition and Requirements

ref

A reference that identifies the document that was updated.

data

A copy of the new document data.

ts

The timestamp, with microsecond resolution, of the event removal.

Examples

The following query changes the history for a document in the "spells" collection. The create event at timestamp 1 is removed.

try
{
    Value result = await client.Query(
        Remove(
            Ref(Collection("spells"), "181388642581742080"),
            1,
            ActionType.Create
        )
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
NullV
result, err := client.Query(
	f.Remove(
		f.Ref(f.Collection("spells"), "181388642581742080"),
		1,
		f.ActionCreate))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
{}
System.out.println(
    client.query(
        Remove(
            Ref(Collection("spells"), Value("181388642581742080")),
            Value(1),
            Action.CREATE
        )
    ).get());
null
client.query(
  q.Remove(
    q.Ref(q.Collection('spells'), '181388642581742080'),
    1,
    'create'
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
null
result = client.query(
  q.remove(
    q.ref(q.collection("spells"), "181388642581742080"),
    ts=1,
    action="create"
  )
)
print(result)
None
Remove(
  Ref(Collection('spells'), '181388642581742080'),
  1,
  'create'
)
null
Query metrics:
  •    bytesIn:   93

  •   bytesOut:   17

  • computeOps:    1

  •    readOps:    0

  •   writeOps:    0

  •  readBytes:  165

  • writeBytes:    0

  •  queryTime: 17ms

  •    retries:    0

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!