1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
type BranchTransaction = {
operations: TransactionOperation[];
};
/**
* A transaction operation
*/
type TransactionOperation = {
insert: TransactionInsertOp;
} | {
update: TransactionUpdateOp;
} | {
["delete"]: TransactionDeleteOp;
};
/**
* Insert operation
*/
type TransactionInsertOp = {
/*
* The table name
*/
table: string;
/*
* The record to insert. The `id` field is optional; when specified, it will be used as the ID for the record.
*/
record: {
[key: string]: any;
};
/*
* The version of the record you expect to be overwriting. Only valid with an
* explicit ID is also set in the `record` key.
*/
ifVersion?: number;
/*
* createOnly is used to change how Xata acts when an explicit ID is set in the `record` key.
*
* If `createOnly` is set to `true`, Xata will only attempt to insert the record. If there's a conflict, Xata
* will cancel the transaction.
*
* If `createOnly` is set to `false`, Xata will attempt to insert the record. If there's no
* conflict, the record is inserted. If there is a conflict, Xata will replace the record.
*/
createOnly?: boolean;
/*
* If set, the call will return the requested fields as part of the response.
*/
columns?: string[];
};
/**
* Update operation
*/
type TransactionUpdateOp = {
/*
* The table name
*/
table: string;
id: RecordID;
/*
* The fields of the record you'd like to update
*/
fields: {
[key: string]: any;
};
/*
* The version of the record you expect to be updating
*/
ifVersion?: number;
/*
* Xata will insert this record if it cannot be found.
*/
upsert?: boolean;
/*
* If set, the call will return the requested fields as part of the response.
*/
columns?: string[];
};
/**
* A delete operation. The transaction will continue if no record matches the ID.
*/
type TransactionDeleteOp = {
/*
* The table name
*/
table: string;
id: RecordID;
/*
* If set, the call will return the requested fields as part of the response.
*/
columns?: string[];
};
/**
* @maxLength 255
* @minLength 1
* @pattern [a-zA-Z0-9_-~:]+
*/
type RecordID = string;