Comparing version 0.0.5 to 0.0.6
@@ -17,9 +17,16 @@ 'use strict'; | ||
return { | ||
equals : f('EQ'), | ||
lte : f('LE'), | ||
lt : f('LT'), | ||
gte : f('GE'), | ||
gt : f('GT'), | ||
beginsWith : f('BEGINS_WITH'), | ||
between : f('BETWEEN') | ||
equals : f('EQ'), | ||
eq : f('NE'), | ||
ne : f('NE'), | ||
lte : f('LE'), | ||
lt : f('LT'), | ||
gte : f('GE'), | ||
gt : f('GT'), | ||
null : f('NULL'), | ||
notNull : f('NOT_NULL'), | ||
contains : f('CONTAINS'), | ||
notContains : f('NOT_CONTAINS'), | ||
within : f('IN'), | ||
beginsWith : f('BEGINS_WITH'), | ||
between : f('BETWEEN') | ||
}; | ||
@@ -110,2 +117,10 @@ }; | ||
if(_.isNull(value) || _.isUndefined(value)) { | ||
result[key] = { | ||
ComparisonOperator : operator | ||
}; | ||
return result; | ||
} | ||
if(!_.isArray(value)) { | ||
@@ -112,0 +127,0 @@ value = [value]; |
{ | ||
"name": "vogels", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"author": "Ryan Fitzgerald <ryan@codebrewstudios.com>", | ||
@@ -5,0 +5,0 @@ "description": "DynamoDB data mapper", |
@@ -170,2 +170,10 @@ 'use strict'; | ||
it('should have not equals clause', function() { | ||
serializer.serializeItem.returns({email: {S: 'foo@example.com'}}); | ||
scan = scan.where('email').ne('foo@example.com'); | ||
scan.request.ScanFilter.email.should.eql({AttributeValueList: [{S: 'foo@example.com'}], ComparisonOperator: 'NE'}); | ||
}); | ||
it('should have less than or equal clause', function() { | ||
@@ -203,2 +211,40 @@ serializer.serializeItem.returns({email: {S: 'foo@example.com'}}); | ||
it('should have not null clause', function() { | ||
scan = scan.where('email').notNull(); | ||
scan.request.ScanFilter.email.should.eql({ComparisonOperator: 'NOT_NULL'}); | ||
}); | ||
it('should have null clause', function() { | ||
scan = scan.where('email').null(); | ||
scan.request.ScanFilter.email.should.eql({ComparisonOperator: 'NULL'}); | ||
}); | ||
it('should have contains clause', function() { | ||
serializer.serializeItem.returns({email: {S: 'foo@example.com'}}); | ||
scan = scan.where('email').contains('foo@example.com'); | ||
scan.request.ScanFilter.email.should.eql({AttributeValueList: [{S: 'foo@example.com'}], ComparisonOperator: 'CONTAINS'}); | ||
}); | ||
it('should have not contains clause', function() { | ||
serializer.serializeItem.returns({email: {S: 'foo@example.com'}}); | ||
scan = scan.where('email').notContains('foo@example.com'); | ||
scan.request.ScanFilter.email.should.eql({AttributeValueList: [{S: 'foo@example.com'}], ComparisonOperator: 'NOT_CONTAINS'}); | ||
}); | ||
it('should have within clause', function() { | ||
serializer.serializeItem.withArgs(schema, {email: 'foo@example.com'}).returns({email: {S: 'foo@example.com'}}); | ||
serializer.serializeItem.withArgs(schema, {email: 'test@example.com'}).returns({email: {S: 'test@example.com'}}); | ||
scan = scan.where('email').within(['foo@example.com', 'test@example.com']); | ||
scan.request.ScanFilter.email.should.eql({ | ||
AttributeValueList: [{S: 'foo@example.com'}, {S: 'test@example.com'}], | ||
ComparisonOperator: 'IN' | ||
}); | ||
}); | ||
it('should have begins with clause', function() { | ||
@@ -205,0 +251,0 @@ serializer.serializeItem.returns({email: {S: 'foo'}}); |
72222
1930