Skip to main content

upsert

Macro upsert 

Source
upsert!() { /* proc-macro */ }
Expand description

prax::upsert! — schema-aware DSL targeting upsert. Top-level keys: where: (required, unique), create: (required), update: (required), include xor select. On hit applies the update: payload; on miss inserts the create: payload.

prax::upsert!(client.user, {
    where: { email: "a@x.com" },
    create: { email: "a@x.com", name: "Alice", active: true, created_at: @(now) },
    update: { name: { set: "Renamed" }, age: { increment: 1 } },
    select: { id: true },
});