Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scan is not implemented correctly according to http://dynastyjs.com/#scan #61

Open
calvinlfer opened this issue Sep 29, 2015 · 3 comments
Assignees
Milestone

Comments

@calvinlfer
Copy link

Hello Victor,

It seems that scan ignores {ExclusiveStartKey: <startkey>} when passed in as an argument, I took a deeper look into this and I found the following
https://github.com/victorquinn/dynasty/blob/master/src/lib/aws-translators.coffee#L106

awsParams =
    TableName: @name
    ScanFilter: {}
    Select: 'SPECIFIC_ATTRIBUTES'
    AttributesToGet: params.attrsGet || [keySchema.hashKeyName]
    Limit: params.limit
    TotalSegments: params.totalSegment
    Segment: params.segment

There is no mention of ExclusiveStartKey. Not too bad to fix this, just need to add
ExclusiveStartKey: params.ExclusiveStartKey if you want it to adhere to the dynastyjs documentation

Also scan should return a LastEvaluatedKey, however when doing
https://github.com/victorquinn/dynasty/blob/master/src/lib/aws-translators.coffee#L128

  @parent.dynamo.scanAsync(awsParams)
    .then (data)->
      dataTrans.fromDynamo(data.Items)
    .nodeify(callback)

The LastEvaluatedKey is not passed to the user as it exists in data.LastEvaluatedKey,
Ideally, this should be doing something along the lines of

@parent.dynamo.scanAsync(awsParams)
    .then (data)->
      result = 
              Items: dataTrans.fromDynamo(data.Items),
              Count: data.Count,
              LastEvaluatedKey: data.LastEvaluatedKey
    .nodeify(callback)

This way the fromDynamo function can remain as is and the information can propagate through to the user

I deduced this information based on the debugger
image

@calvinlfer
Copy link
Author

I tried to add the scan features but I'm not too familiar with coffee script. Please feel free to decide what to do

@timhuff
Copy link
Contributor

timhuff commented Dec 15, 2015

This problem pulled my project to a screetching halt and it's something I have to get out the door. If anyone else is in a similar situation, feel free to use my fork until Victor gets this sorted out. You can do this by changing your package.json file to say "dynasty":"git://github.com/timhuff/dynasty-1.git" and then running an npm install. My fork is the same exact thing (as of the time of this writing) with the only difference being that you can run table.scan({ExclusiveStartKey:{someHashKey: 1234}}) and it will actually do what the documentation says it'll do. You can also add to that object someRangeKey, if you'd like. I would recommend constraining the ExclusiveStartKey to only contain properties that are keys.

@victorquinn victorquinn added this to the 1.0 milestone Mar 18, 2017
@victorquinn victorquinn self-assigned this Mar 18, 2017
@aterreno
Copy link
Contributor

No progress on this @victorquinn ? It has been more than a year now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants