Skip to content

Commit

Permalink
Changed from transaction to update.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher M. Baker committed Feb 6, 2015
1 parent 038a1e1 commit abc1b25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 57 deletions.
38 changes: 0 additions & 38 deletions dock

This file was deleted.

29 changes: 10 additions & 19 deletions lib/chillhub.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,26 +244,17 @@ var createAttachmentResource = function(attachment, key, initialValue, onChange,
} else if (onChange === undefined) {
callback(new UndefinedPropertyError('onChange'));
} else {
attachment.transaction(function(currentdata) {
if(currentdata == null) {
return{key: initialValue};
} else {
currentdata[key] = initialValue;
return currentdata;
}
var data = { };
data[key] = initialValue;

}, function(error, committed, snap) {
if (error) {
console.log("Resource creation transaction failed for resource " + key);
} else if (!committed) {
console.log("Looks like we aborted the creation transaction for resource " + key);
} else {
if (onChange) {
attachment.child(key).on("value", onChange);
}
callback(null, attachment);
}
attachment.update(data, function(error) {
if (error) return callback(error);

if (onChange) {
attachment.child(key).on("value", onChange);
}

callback(null, attachment);
});
return;
}
}

0 comments on commit abc1b25

Please sign in to comment.