-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing add
Method in Upsert for Transactional Writes
#301
Comments
add
Method in Upsert for Transactional Writes Following Update #296
add
Method in Upsert for Transactional Writes Following Update #296add
Method in Upsert for Transactional Writes
I was messing around in the playground and I've discovered that the update methods work, but they're missing types. For example, with the entity shown above, I can do this: service.transaction.write((entities) => [
// casting entities as any allows me to access the update methods.
(entities as any).sum
.upsert({ name: 'a' })
.add({ value: 1 })
.commit(),
]).go(); and here's the transact write, which looks right to me: {
"TransactItems": [
{
"Update": {
"TableName": "your_table_name",
"UpdateExpression": "SET #__edb_e__ = :__edb_e___u0, #__edb_v__ = :__edb_v___u0, #name = :name_u0 ADD #value :value_u0",
"ExpressionAttributeNames": {
"#__edb_e__": "__edb_e__",
"#__edb_v__": "__edb_v__",
"#name": "name",
"#value": "value"
},
"ExpressionAttributeValues": {
":__edb_e___u0": "sum",
":__edb_v___u0": "1",
":name_u0": "a",
":value_u0": 1
},
"Key": {
"pk": "$someapp$sum_1#name_a"
}
}
}
]
} |
Thanks for putting this together, I hope to address the typing sometime this week 👍 |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
The update methods like
add
are not available forupsert
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
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!
The text was updated successfully, but these errors were encountered: