Permalink
Browse files

Merge branch 'master' of https://github.com/yjh0502/simpledb into yjh…

…0502-master
  • Loading branch information...
2 parents d70f883 + 6592de3 commit 4cda48cb5eb78ea05a26584837e34696162112fc @rjrodger committed Apr 9, 2011
Showing with 44 additions and 4 deletions.
  1. +4 −0 README.md
  2. +6 −2 lib/simpledb.js
  3. +34 −2 test/simpledb.test.js
View
@@ -341,6 +341,10 @@ deleted.
sdb.deleteItem('<domain>','<itemname>',[ '<attr>', ... ]function( error, result, meta ){
console.log("I felt like destroying something beautiful. "+JSON.stringify(res))
})
+
+ sdb.deleteItem('<domain>','<itemname>',{ '<attr>': [<value1>, ... ], ... }function( error, result, meta ){
+ console.log("I don't know what to write about. "+JSON.stringify(res))
+ })
### select: `sdb.select( query, override, callback )`
View
@@ -444,8 +444,12 @@ exports.SimpleDB = function(opts,logger) {
var act = 'DeleteAttributes'
var q = {DomainName:domain,ItemName:itemname}
- for( var aI = 1; aI <= attrs.length; aI++ ) {
- q['Attribute.'+aI+'.Name'] = attrs[aI-1]
+ if (Array.isArray(attrs)) {
+ for( var aI = 1; aI <= attrs.length; aI++ ) {
+ q['Attribute.'+aI+'.Name'] = attrs[aI-1]
+ }
+ } else {
+ putattrs(q,attrs,'');
}
applyoverride(q,override)
View
@@ -314,6 +314,31 @@ module.exports = {
assert.equal('b2',res[1].$ItemName)
assert.equal('two', res[1].field )
+ ;sdb.deleteItem('simpledbtest','item1', {'woz': ['one']},function(err,res,meta) {
+ debugres(err,res,meta)
+
+ ;sdb.getItem('simpledbtest','item1',function(err,res,meta){
+ debugres(err,res,meta)
+ assert.isNull(err)
+ assert.equal('item1',res.$ItemName)
+ assert.equal(1,parseInt(res.foo,10))
+ assert.equal('BAR',res.bar)
+ assert.equal('two',res.woz)
+ assert.equal("'n",res.quote)
+
+ ;sdb.deleteItem('simpledbtest','item1', ['foo', 'bar'],function(err,res,meta) {
+ debugres(err,res,meta)
+ assert.isNull(err)
+
+ ;sdb.getItem('simpledbtest','item1',function(err,res,meta){
+ debugres(err,res,meta)
+ assert.isNull(err)
+ assert.equal('item1',res.$ItemName)
+ assert.isNull(res.foo)
+ assert.isNull(res.bar)
+ assert.equal('two',res.woz)
+ assert.equal("'n",res.quote)
+
;sdb.deleteItem('simpledbtest','item1',function(err,res,meta){
debugres(err,res,meta)
assert.isNull(err)
@@ -331,7 +356,7 @@ module.exports = {
debugres(err,res,meta)
assert.isNotNull(err)
- }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) })
+ }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) })
},
example: function() {
@@ -363,9 +388,16 @@ function debugres(err,res,meta) {
*/
}
+assert.isNull = function(obj) {
+ return null == obj;
+}
+
+assert.isNotNull = function(obj) {
+ return null != obj;
+}
if( 'run' == process.argv[2] ) {
for( fname in module.exports ) {
module.exports[fname]()
}
-}
+}

0 comments on commit 4cda48c

Please sign in to comment.