Comments (6)
I think this library is handling things in line with DynamoDB best practices and the intent of the underlying APIs.
In your example you are sending the whole fooFromDB
entity in the Foos.update
call, but the underlying UpdateItem
API updates items with an UpdateExpression - i.e. it's built for only sending the changes.
I'd update the name like this:
await Foos.update({
id: foo.id,
name: 'Bob'
);
Sending partial updates means you don't end up clobbering concurrent, non-overlapping writes.
from dynamodb-toolbox.
I should also point out that the same test code fails (for the same reason) if you use put()
instead of update()
. The workaround still applies in either case.
Whether or not update()
should support my first example, I'll leave up to Jeremy.
from dynamodb-toolbox.
That's a fair point on put()
, and maybe for the sake of consistency update()
should work the same way.
What should happen in the case where the entity
passed in doesn't match the Entity object?
- Save it anyway
- Error out
- Silently use what's defined in the Entity object?
from dynamodb-toolbox.
Sorry for the late reply. Looking at this now.
from dynamodb-toolbox.
This makes sense. The entity
attribute could easily be stripped out when writing both updates
and puts
, but I'm wondering what we should do with the created
and modified
times. entity
makes sense not to be overwritten, but created
definitely should be updated. Perhaps modified
should be stripped out as well?
from dynamodb-toolbox.
I've decided to leave _et
field manipulation in. You probably should not modify the _et
field directly, but you have the ability to if you like. I've added a patch that adds the entity alias to the attributes, so your update will now work correctly.
from dynamodb-toolbox.
Related Issues (20)
- Overlays break many constructor inputs HOT 1
- Error when importing abstraction that uses dynamodb-toolbox HOT 1
- Bug on Item.get, where unneeded properties are required HOT 2
- Error when sending EntityV2 `GetItemCommand` with property of type `binary()` HOT 3
- Undefined dependencies for Index keys cause Update / Put failures
- Recent versions do not run onDefault if dependsOn contains undefined parameter HOT 2
- Got Error: Please provide a valid entity definition HOT 2
- Created is changing with puts and is always the same as modified HOT 1
- Is `transform` valid for partition key? HOT 2
- Unable to convert date string to JS Date instance
- getting error for formatter.missingAttribute when using computeKey function to build pk and sk HOT 3
- Unable to save null values in V1 HOT 9
- Type inference for query responses with multiple entities HOT 3
- V1 Migration BatchGetCommand type mismatch HOT 5
- Suggestion: date() type HOT 3
- DeleteItemCommand getting empty input for computedKey HOT 4
- Cannot define index with only `partitionKey` in v1.1 HOT 3
- Application built with esbuild possibly broken after `experimentalDecorators` was activated HOT 4
- $add signature for Sets not matching documentation HOT 2
- EQ operator missing from Range Conditions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dynamodb-toolbox.