Comparing version 0.5.4 to 0.5.5
@@ -204,2 +204,8 @@ 'use strict'; | ||
_.each(schema.secondaryIndexes, function (rangeKey) { | ||
if(hashKey[rangeKey]){ | ||
obj[rangeKey] = hashKey[rangeKey]; | ||
} | ||
}); | ||
} else { | ||
@@ -303,3 +309,9 @@ obj[schema.hashKey] = hashKey; | ||
_.each(schema.secondaryIndexes, function (rangekey) { | ||
if(item[rangekey]){ | ||
result[rangekey] = internals.deserializeAttribute(item[rangekey], schema.attrs[rangekey]); | ||
} | ||
}); | ||
return result; | ||
}; |
{ | ||
"name": "vogels", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"author": "Ryan Fitzgerald <ryan@codebrewstudios.com>", | ||
@@ -5,0 +5,0 @@ "description": "DynamoDB data mapper", |
@@ -73,2 +73,13 @@ 'use strict'; | ||
it('should handle local secondary index keys', function () { | ||
schema.String('email', {hashKey: true}); | ||
schema.Number('age', {rangeKey: true}); | ||
schema.String('name', { secondaryIndex: true }); | ||
var data = { email : 'test@example.com', age: 22, name: 'Foo Bar' }; | ||
var keys = serializer.buildKey(data, null, schema); | ||
keys.should.eql({email: {S: 'test@example.com'}, age: {N : '22'}, name: {S: 'Foo Bar'}}); | ||
}); | ||
it('should handle global secondary index keys', function () { | ||
@@ -89,2 +100,3 @@ schema.String('email', {hashKey: true}); | ||
}); | ||
}); | ||
@@ -114,4 +126,15 @@ | ||
it('should global secondary index keys', function () { | ||
it('should deserialize local secondary index keys', function () { | ||
schema.String('email', {hashKey: true}); | ||
schema.Number('age', {rangeKey: true}); | ||
schema.String('name', { secondaryIndex: true }); | ||
var serializedItem = {email : {S : 'test@example.com'}, age : {N : '22'}, name : {S: 'Foo Bar'}}; | ||
var keys = serializer.deserializeKeys(schema, serializedItem); | ||
keys.should.eql({email: 'test@example.com', age: 22, name: 'Foo Bar'}); | ||
}); | ||
it('should deserialize global secondary index keys', function () { | ||
schema.String('email', {hashKey: true}); | ||
schema.Number('age'); | ||
@@ -118,0 +141,0 @@ schema.String('name'); |
156657
3685