Skip to content

Conversation

@bfil
Copy link

@bfil bfil commented Jul 11, 2012

Boolean values should be converted to numbers on DynamoDB, in this way we can have the following item with boolean properties:

var item = { hash: "whatever", isBetter: true, isWorse: false };
item.put();

And it can be retrieved and tested in the following way:

var item = table.get_item({hash: "whatever"});
item.isBetter == true; // true
item.isWorse == false; // true

Because in Javascript (and many other languages):

1 == true; // true
0 == false; // true

@ryanfitz
Copy link
Member

This is a great fix, I'm going to pull this in for the next major update to dynode as this changes the way data is stored. I also have to add in some details to the readme about boolean handling.

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 this pull request may close these issues.

2 participants