Giter Club home page Giter Club logo

Comments (11)

adrianpraja avatar adrianpraja commented on July 17, 2024

please try this.ConsumedCapacity inside the callback

DynamoDB
     .table(tableName)
     .where('partitionKey').eq(partitionValue)
     .where('sortKey').begins_with(sortValue)
     .query(function(err,data) {
          console.log(err,data, this.ConsumedCapacity )
     })

from dynamodb-oop.

teebu avatar teebu commented on July 17, 2024

Im getting null value.

from dynamodb-oop.

adrianpraja avatar adrianpraja commented on July 17, 2024

I see, I'll have a look at it today and get back to you

from dynamodb-oop.

adrianpraja avatar adrianpraja commented on July 17, 2024

Hi,

I've published 0.1.51 which defaults to 'TOTAL' for ReturnConsumedCapacity
you can override with return_consumed_capacity('NONE') // 'NONE' 'INDEXES' 'TOTAL'

Also added it to documentation

Please re-open the issue if you're still getting null

Thanks

from dynamodb-oop.

teebu avatar teebu commented on July 17, 2024

version: "0.1.64"

Still getting: consumed: null

DynamoDB
    .table(dynamoTable)
    .where(key).eq(value)
    .return(DynamoDB.NONE)
    .return_consumed_capacity('TOTAL') // 'TOTAL' / 'INDEXES' / NONE
    .insert_or_replace(tmp_data, function (err, res) {
      if (err) {
        return callback(err)
      } else {
        //console.log( 'update result:', err, res )
        console.log('consumed:', this.ConsumedCapacity)
        return callback(null, res)
      }
    })

from dynamodb-oop.

adrianpraja avatar adrianpraja commented on July 17, 2024

Hi teebu,

there was a recent but resetting ConsumedCapacity after each call,

I've published 0.1.66 that has it fixed

Thanks.

from dynamodb-oop.

teebu avatar teebu commented on July 17, 2024

Yes that fixed it. Keep up the great work.

from dynamodb-oop.

teebu avatar teebu commented on July 17, 2024

How do you get consumed capacity when using async?

async function getItem(table, key, value) {
  return DynamoDB
    .table(table)
    .return_consumed_capacity('TOTAL') // 'TOTAL' | 'INDEXES' | NONE
    .where(key).eq(value)
    .get()
}
const res = await getItem('table', 'id', '123')
console.log(res) // only contains the returned data

from dynamodb-oop.

adrianpraja avatar adrianpraja commented on July 17, 2024

Heyy,

I dont have a solution for return_consumed_capacity() when using async

If you have any ideas please let me know

from dynamodb-oop.

teebu avatar teebu commented on July 17, 2024

No good ideas. Maybe add a method to the returned item so it doesn't actually change the returned object's data?

from dynamodb-oop.

adrianpraja avatar adrianpraja commented on July 17, 2024

yes, that could be a solution, something like .return_raw_result(true)

from dynamodb-oop.

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.