Giter VIP home page Giter VIP logo

Comments (6)

omichowdhury avatar omichowdhury commented on September 26, 2024

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.

SethO avatar SethO commented on September 26, 2024

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.

omichowdhury avatar omichowdhury commented on September 26, 2024

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?

  1. Save it anyway
  2. Error out
  3. Silently use what's defined in the Entity object?

from dynamodb-toolbox.

jeremydaly avatar jeremydaly commented on September 26, 2024

Sorry for the late reply. Looking at this now.

from dynamodb-toolbox.

jeremydaly avatar jeremydaly commented on September 26, 2024

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.

jeremydaly avatar jeremydaly commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.