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

Added Scan features #62

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/lib/aws-translators.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ module.exports.scan = (params, options, callback, keySchema) ->
Limit: params.limit
TotalSegments: params.totalSegment
Segment: params.segment
ExclusiveStartKey: params.ExclusiveStartKey

scanFilterFunc = (filter) ->
obj = awsParams.ScanFilter
Expand All @@ -125,7 +126,10 @@ module.exports.scan = (params, options, callback, keySchema) ->

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't merged this yet because this signature is not in line with the rest of Dynasty.

I try to abstract the internals of Dynamo from the end user of Dynasty. Hence why all of the other API calls return objects with slightly different names and without capitalizing everything.

Also, this introduces a non-trivial breaking change to Scan. It used to return just an array of objects, now this new object with multiple keys.

Anyway, thanks for the changes! I will do my best to work with them and "Dynasty-ify" them before merging.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @victorquinn

.nodeify(callback)

module.exports.putItem = (obj, options, callback) ->
Expand Down
6 changes: 5 additions & 1 deletion test/src/aws-translators.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@ describe 'aws-translators', () ->
hashKeyName: 'bar'
hashKeyType: 'S'
.then (data) ->
expect(data).to.deep.equal(rofl: 'lol')
expect(data).to.deep.equal({
Count: undefined
Items: {rofl: 'lol'}
LastEvaluatedKey
})

it 'should call getItem of aws', () ->
sandbox.spy(dynastyTable.parent.dynamo, "scan")
Expand Down