Skip to content

Commit abc1b25

Browse files
author
Christopher M. Baker
committed
Changed from transaction to update.
1 parent 038a1e1 commit abc1b25

File tree

2 files changed

+10
-57
lines changed

2 files changed

+10
-57
lines changed

dock

Lines changed: 0 additions & 38 deletions
This file was deleted.

lib/chillhub.js

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -244,26 +244,17 @@ var createAttachmentResource = function(attachment, key, initialValue, onChange,
244244
} else if (onChange === undefined) {
245245
callback(new UndefinedPropertyError('onChange'));
246246
} else {
247-
attachment.transaction(function(currentdata) {
248-
if(currentdata == null) {
249-
return{key: initialValue};
250-
} else {
251-
currentdata[key] = initialValue;
252-
return currentdata;
253-
}
247+
var data = { };
248+
data[key] = initialValue;
254249

255-
}, function(error, committed, snap) {
256-
if (error) {
257-
console.log("Resource creation transaction failed for resource " + key);
258-
} else if (!committed) {
259-
console.log("Looks like we aborted the creation transaction for resource " + key);
260-
} else {
261-
if (onChange) {
262-
attachment.child(key).on("value", onChange);
263-
}
264-
callback(null, attachment);
265-
}
250+
attachment.update(data, function(error) {
251+
if (error) return callback(error);
252+
253+
if (onChange) {
254+
attachment.child(key).on("value", onChange);
255+
}
256+
257+
callback(null, attachment);
266258
});
267-
return;
268259
}
269260
}

0 commit comments

Comments
 (0)