Description
Describe the bug
The update methods like add
are not available for upsert
when using transactional writes for ElectroDB entities. Using these methods results in a TypeScript error.
ElectroDB Version
2.10.0
ElectroDB Playground Link
ElectroDB Playground
Entity/Service Definitions
/* Model queries, see results, share with friends */
import { Entity, Service } from "electrodb";
const table = "your_table_name";
/* Tasks Entity */
const sum = new Entity(
{
model: {
entity: "sum",
version: "1",
service: "someapp"
},
attributes: {
name: {
type: "string",
required: true
},
value: {
type: "number",
required: true,
default: 1,
}
},
indexes: {
main: {
pk: {
field: "pk",
composite: ["name"]
}
}
}
},
{ table }
);
const service = new Service({ sum });
// Works fine:
sum
.upsert({ name: 'a' })
.add({ value: 1 })
.go();
// Error case:
service.transaction.write((entities) => [
entities.sum
.upsert({ name: 'a' })
.add({ value: 1 }) // add doesn't exist here.
.commit(),
]);
Expected behavior
After #296, I expected to be able to use update methods for transactional writes just like when using upsert on an entity directly.
Errors
Property 'add' does not exist on type 'UpsertRecordOperationOptionsTransaction<string, string, string, { model: { entity: string; version: string; service: string; }; attributes: { name: { type: "string"; required: true; }; value: { type: "number"; required: true; default: number; }; }; indexes: { ...; }; }, ResponseItem<...>>'.(2339)
Additional context
#296 introduced update methods to upsert.
Thank you!