Giter Club home page Giter Club logo

Comments (10)

adrianpraja avatar adrianpraja commented on August 17, 2024 1

I see the problem, I'll try to reproduce

from dynamodb-oop.

adrianpraja avatar adrianpraja commented on August 17, 2024

Hi Luiz,

Looks like a bug!

Can you add the following line and paste the output of it
dynamodb.on('beforeRequest', console.log )

Thanks

from dynamodb-oop.

luizstacio avatar luizstacio commented on August 17, 2024

I will make this and past the log here

from dynamodb-oop.

adrianpraja avatar adrianpraja commented on August 17, 2024

Allright, i'll check it and get back to you

from dynamodb-oop.

luizstacio avatar luizstacio commented on August 17, 2024
scan { TableName: 'table',
  Select: undefined,
  ProjectionExpression: undefined,
  ExpressionAttributeNames: { '#domain': 'domain', '#create_at': 'create_at' },
  FilterExpression: '( attribute_not_exists(#domain) ) AND \n( #create_at BETWEEN :create_at_1_v1 AND :create_at_2_v1 )',
  ExpressionAttributeValues: 
   { ':create_at_1_v1': { N: '1479772800000' },
     ':create_at_2_v1': { N: '1479945540000' } },
  ReturnConsumedCapacity: 'TOTAL',
  ExclusiveStartKey: undefined }

scan { TableName: 'table',
  Select: undefined,
  ProjectionExpression: undefined,
  ExpressionAttributeNames: { '#domain': 'domain', '#create_at': 'create_at' },
  FilterExpression: '( attribute_not_exists(#domain) ) AND \n( #create_at BETWEEN :create_at_1_v2 AND :create_at_2_v2 )',
  ExpressionAttributeValues: 
   { ':create_at_1_v1': { N: '1479772800000' },
     ':create_at_2_v1': { N: '1479945540000' },
     ':create_at_1_v2': { N: '1479772800000' },
     ':create_at_2_v2': { N: '1479945540000' } },
  ReturnConsumedCapacity: 'TOTAL',
  ExclusiveStartKey: { id: { S: '2cb44130-99e5-11a6-21b5-0203581001e5' } } }

from dynamodb-oop.

adrianpraja avatar adrianpraja commented on August 17, 2024

Seems to me that the error is produced by the nested call

I was not able to reproduce the same

I'm using:

	DynamoDB.on('beforeRequest', console.log )
	DynamoDB
		.table($tableName)
		.having('domain').null()
		.having('create_at').between(1,3)
		.scan( function(err, data) {

			DynamoDB
				.table($tableName)
				.having('domain').null()
				.having('create_at').between(1,3)
				.resume({id: {'S': "test"}})
				.scan( function(err, data) {

				})
		})

and my local output is

scan { TableName: 'test_hash_range',
  Select: undefined,
  ProjectionExpression: undefined,
  ExpressionAttributeNames: { '#domain': 'domain', '#create_at': 'create_at' },
  FilterExpression: '( attribute_not_exists(#domain) ) AND \n( #create_at BETWEEN :create_at_1_v1 AND :create_at_2_v1 )',
  ExpressionAttributeValues: { ':create_at_1_v1': { N: '1' }, ':create_at_2_v1': { N: '3' } },
  ReturnConsumedCapacity: 'TOTAL' }
scan { TableName: 'test_hash_range',
  Select: undefined,
  ProjectionExpression: undefined,
  ExpressionAttributeNames: { '#domain': 'domain', '#create_at': 'create_at' },
  FilterExpression: '( attribute_not_exists(#domain) ) AND \n( #create_at BETWEEN :create_at_1_v1 AND :create_at_2_v1 )',
  ExpressionAttributeValues: { ':create_at_1_v1': { N: '1' }, ':create_at_2_v1': { N: '3' } },
  ReturnConsumedCapacity: 'TOTAL',
  ExclusiveStartKey: { id: { S: 'test' } } }

ExpressionAttributeValues seems fine.

are you using this.scan() for the second call ?

from dynamodb-oop.

luizstacio avatar luizstacio commented on August 17, 2024

No completly! I create a recursive function and only call again passing LastEvaluatedKey.

Clinic.findAllClinicsWithoutSitesBetween = function (init, end) {
  const initDate = new Date(init);
  const endDate = new Date(end);

  const preparatedQuery = repository
                            .getTableConnection()
                            .having('domain').null()
                            .having('create_at').between(+initDate, +endDate);

  return Clinic._findAllClinicsWithoutSites(preparatedQuery);
}

Clinic._findAllClinicsWithoutSites = function (preparatedQuery, $lastKey, finalData = []) {
  let def = new Defer();

  preparatedQuery
      .resume($lastKey)
      .scan(function(err, data) {
          if (err) return def.reject(err);

          finalData.push(...data);

          if (this.LastEvaluatedKey === null) {
            return def.resolve(finalData);
          }

          setTimeout(() => {
              Clinic
                ._findAllClinicsWithoutSites(preparatedQuery, this.LastEvaluatedKey, finalData)
                .then(def.resolve)
                .catch(def.reject);
          }, 500);
      });

    return def.promise;
}

from dynamodb-oop.

adrianpraja avatar adrianpraja commented on August 17, 2024

Oh, I see

I finally was able to get something similar with:

var dynamodb = DynamoDB.table($tableName)
dynamodb
			.having('domain').null()
			.having('create_at').between(1,3)
			.scan( function(err, data) {
				dynamodb
					.having('domain').null()
					.having('create_at').between(1,3)
					.resume({id: {'S': "test"}})
					.scan( function(err, data) {
						
					})
			})

Unfortunately you can not re-use the query with the current version of this library.

You will have to do the DynamoDB.table() every time

I'm adding a self note to reset the internal vars after each query and
probably the next version will work the way you;re trying to use it.

from dynamodb-oop.

luizstacio avatar luizstacio commented on August 17, 2024

😱 hehe no problem I will wait for this update. In the moment I will continue using the native sdk for this specific part.

Thanks man!

from dynamodb-oop.

adrianpraja avatar adrianpraja commented on August 17, 2024

released version 0.1.60,

with minimum changes this fixed my local replication of your described issue.

I still can not recommend using

	var $users = DynamoDB.table('users')
	$users.insert(...)
	$users.update(...)
	...

there are no tests to confirm that is ready for this change.

I'm closing the issue for now, please re-open it if you still see the issue.

Thanks
</adrian>

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.