Skip to content

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

@calvinlfer

Description

@calvinlfer

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions