Giter Site home page Giter Site logo

Comments (5)

ruicsh avatar ruicsh commented on September 27, 2024

hi @mikestopcontinues, thanks for your suggestion. I have it implemented on PR #10 but don't have access to a DDB right now so I can't test one assumption, maybe you can help?

The docs are not very explicit about how the UpdateExpression should be constructed. I'm guessing it's just a simple concatenation of the different clauses starting with keywords SET/ADD/REMOVE/DELETE:

Given this input to dynoexpr:

{
  UpdateSet: { ufoo: 'ufoo - 2' },
  UpdateRemove: { rfoo: 'rbar' },
  UpdateAdd: { afoo: 'abar' },
  UpdateDelete: { dfoo: 'dbar' },
}

It would produce:

{
  UpdateExpression:
    'SET #nff12 = #nff12 - :v862c REMOVE #nff12, #n978b ADD #nb01c :ve948 DELETE #nd358 :v45cc',
  ExpressionAttributeNames: {
    '#n978b': 'rfoo',
    '#nb01c': 'afoo',
    '#nd358': 'dfoo',
    '#nff12': 'ufoo',
  },
  ExpressionAttributeValues: {
    ':v0e91': 'rbar',
    ':v45cc': 'dbar',
    ':v862c': 2,
    ':ve948': 'abar',
  },
}

Is this your understanding, too? Cheers

from dynoexpr.

mikestopcontinues avatar mikestopcontinues commented on September 27, 2024

That was my understanding as well. I'll test it today. Thanks for your help!

from dynoexpr.

mikestopcontinues avatar mikestopcontinues commented on September 27, 2024

Things are looking good! SET, REMOVE, and ADD (add for numbers) all work concatenated with a space. I was also able to get ADD (for sets) and DELETE working too, using docClient.createSet() for the value.

On that front, does it make sense to automatically wrap any arrays in createSet() when using ADD and DELETE update actions? Does that get in the way of any other behavior?

from dynoexpr.

ruicsh avatar ruicsh commented on September 27, 2024

great, I'm closing this issue now as it's fixed by the PR. I've created a new issue #11 for your createSet suggestion.. if you could add an example of the expected behavior to that issue, it would be of great help

from dynoexpr.

mikestopcontinues avatar mikestopcontinues commented on September 27, 2024

Thanks again!

from dynoexpr.

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.