commitBatchcommandsince 0.1
Writes several commits in one transaction.
Request
umwelt call story.umw commitBatch '{
"commits": [
{
"projectId": "ball",
"attemptId": "unmasking",
"event": {
"id": "unmasking",
"type": "scene",
"title": "The unmasking",
"position": { "tick": 8 },
"participants": ["bob", "duchess"],
"provenance": { "origin": { "kind": "human" } }
},
"records": [
{
"kind": "holding",
"id": "duchess-name",
"position": { "tick": 8 },
"provenance": { "origin": { "kind": "human" } },
"holder": "duchess",
"attitude": "knows",
"confidence": 1,
"accessibility": "available",
"acquisition": { "kind": "witnessed", "eventId": "unmasking" },
"claim": {
"subject": "bob",
"predicate": "umwelt:name",
"object": { "kind": "value", "value": "Bob" },
"polarity": true
}
}
]
},
{
"projectId": "ball",
"attemptId": "supper",
"event": {
"id": "supper",
"type": "scene",
"title": "Supper",
"position": { "tick": 9 },
"participants": ["ana", "bob", "duchess"],
"provenance": { "origin": { "kind": "human" } }
},
"records": [
{
"kind": "awareness",
"id": "ana-meets-duchess",
"position": { "tick": 9 },
"provenance": { "origin": { "kind": "human" } },
"holder": "ana",
"target": "duchess"
}
]
}
]
}'Request
const result = await client.commitBatch({
commits: [
{
projectId: 'ball',
attemptId: 'unmasking',
event: {
id: 'unmasking',
type: 'scene',
title: 'The unmasking',
position: { tick: 8 },
participants: ['bob', 'duchess'],
provenance: provenance,
},
records: [
{
kind: 'holding',
id: 'duchess-name',
position: { tick: 8 },
provenance: provenance,
holder: 'duchess',
attitude: 'knows',
confidence: 1,
accessibility: 'available',
acquisition: { kind: 'witnessed', eventId: 'unmasking' },
claim: {
subject: 'bob',
predicate: 'umwelt:name',
object: { kind: 'value', value: 'Bob' },
polarity: true,
},
},
],
},
{
projectId: 'ball',
attemptId: 'supper',
event: {
id: 'supper',
type: 'scene',
title: 'Supper',
position: { tick: 9 },
participants: ['ana', 'bob', 'duchess'],
provenance: provenance,
},
records: [
{
kind: 'awareness',
id: 'ana-meets-duchess',
position: { tick: 9 },
provenance: provenance,
holder: 'ana',
target: 'duchess',
},
],
},
],
});Request
var result = engine.CommitBatch(new CommitBatchPayload
{
Commits = new()
{
new CommitInput
{
ProjectId = "ball",
AttemptId = "unmasking",
Event = new EventInput
{
Id = "unmasking",
Type = "scene",
Title = "The unmasking",
Position = new Position { Tick = 8 },
Participants = new() { "bob", "duchess" },
Provenance = provenance,
},
Records = new()
{
new RecordInput.Holding
{
Id = "duchess-name",
Position = new Position { Tick = 8 },
Provenance = provenance,
Holder = "duchess",
Attitude = Attitude.Knows,
Confidence = 1.0,
Accessibility = Accessibility.Available,
Acquisition = new Acquisition.Witnessed { EventId = "unmasking" },
Claim = new Claim
{
Subject = "bob",
Predicate = "umwelt:name",
Object = new ClaimObject.ValueClaimObject
{
Value = JsonSerializer.SerializeToElement("Bob"),
},
Polarity = true,
},
},
},
},
new CommitInput
{
ProjectId = "ball",
AttemptId = "supper",
Event = new EventInput
{
Id = "supper",
Type = "scene",
Title = "Supper",
Position = new Position { Tick = 9 },
Participants = new() { "ana", "bob", "duchess" },
Provenance = provenance,
},
Records = new()
{
new RecordInput.Awareness
{
Id = "ana-meets-duchess",
Position = new Position { Tick = 9 },
Provenance = provenance,
Holder = "ana",
Target = "duchess",
},
},
},
},
});Response
[
{
"eventId": "unmasking",
"recordIds": ["duchess-name"],
"transitionIds": [],
"version": 12,
"warnings": []
},
{
"eventId": "supper",
"recordIds": ["ana-meets-duchess"],
"transitionIds": [],
"version": 13,
"warnings": []
}
]Payload
| Field | Type | Description |
|---|---|---|
commitsrequired | CommitInput[] | The commits, in order. Each is a full commit payload, all on the same timeline. |
Result
A list of CommitOutcome, each with:
| Field | Type | Description |
|---|---|---|
eventIdalways | string | The event written, with the id given or generated. |
recordIdsalways | string[] | The records written, in order. |
transitionIdsalways | string[] | The transitions written, in order. |
versionalways | integer | The version this commit received. Reads at an earlier asOfVersion do not see it. |
warnings | Warning[] | UNKNOWN_PREDICATE (open vocabulary) or SECRET_BREACH. Warnings never block a write. |
Rules
One transaction. If one commit fails, none is written.
One timeline. Every commit of a batch must target the same timeline.
Errors
VALIDATION_FAILEDA commit is invalid, or the commits target different timelines.NOT_FOUNDThe project or timeline does not exist.VERSION_CONFLICTexpectedVersion is no longer the head of the timeline.CONFLICTThe attemptId was already used with a different request.INVALID_STATEThe timeline is a draft that was promoted or discarded, and accepts no more writes.HANDSHAKE_REQUIREDOver the protocol, hello was not sent first.Every code is listed in Errors.
See also
Was this page helpful?