Mutations
The Node SDK uses the same mutation API as the Next.js server client.
Upsert
Create or update an entity using Pylo's __search_value pattern. If a matching record is found,
it's updated — otherwise a new record is created.
example.ts
1
2
3
4
5
6
7
8
9
10
11
const result = await pylo.invoice.upsert({
__search_value: {
field: 'invoice_number',
value: 'INV-001',
not_found_behavior: 'create',
},
invoice_number: 'INV-001',
amount_net: 1000,
});
// result: { id: string }With relations
Use _set to connect related entities during upsert:
example.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
await pylo.invoice.upsert({
__search_value: {
field: 'invoice_number',
value: 'INV-001',
not_found_behavior: 'create',
},
invoice_number: 'INV-001',
amount_net: 1500,
customer_set: {
__search_value: {
field: 'customer_number',
value: 'C-001',
not_found_behavior: 'create',
},
name: 'Acme Corp',
},
});Delete
example.ts
1
2
const result = await pylo.invoice.delete(['invoice-uuid-1', 'invoice-uuid-2']);
// result: { success: boolean }