
Untitled
By: a guest on
May 9th, 2012 | syntax:
None | size: 1.63 KB | hits: 15 | expires: Never
var Node;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
module.exports = Node = (function() {
__extends(Node, PropertyContainer);
function Node() {
Node.__super__.constructor.apply(this, arguments);
}
Node.prototype["delete"] = function(_, force) {
var message, relationship, relationships, response, _i, _len;
if (force == null) {
force = false;
}
if (!this.exists) {
return;
}
console.log("about to delete " + this + "...");
try {
relationships = this.all(null, _);
if (relationships.length && !force) {
throw new Error("Could not delete " + this + "; still has relationships.");
}
for (_i = 0, _len = relationships.length; _i < _len; _i++) {
relationship = relationships[_i];
relationship["delete"](_);
}
response = request.del(this.self, _);
if (response.statusCode !== status.NO_CONTENT) {
message = '';
switch (response.statusCode) {
case status.NOT_FOUND:
message = 'Node not found';
break;
case status.CONFLICT:
message = 'Node could not be deleted (still has relationships?)';
}
throw new Error(message);
}
console.log("finished deleting " + this + ".");
} catch (error) {
throw adjustError(error);
}
};
return Node;
})();