ogm
Version:
OGM for OrientDB
71 lines (56 loc) • 2.21 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', {
value: true
});
var _bind = Function.prototype.bind;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _ = require('./');
var debug = require("debug")("ogm");
var E = (function () {
function E(inV, outV, props) {
_classCallCheck(this, E);
var _this = this;
if (inV && typeof inV === 'object') {
Object.keys(inV).forEach(function (key) {
_this[key] = inV[key];
});
} else {
this['in'] = inV;
this.out = outV;
this.props = props;
}
}
_createClass(E, [{
key: 'save',
value: function save() {
debug('saving edge', this);
var r = _.session.db.create('EDGE', this._OGM_CLASS_NAME).from(typeof this.inV === 'object' ? this.inV['@rid'] : this.inV).to(typeof this.outV === 'object' ? this.outV['@rid'] : this.outV);
if (this.props) {
r.set(this.props);
}
return r.one();
}
}], [{
key: 'delete',
value: function _delete(q) {
var r = _.session.db['delete']().from(this._OGM_CLASS_NAME || 'E');
if (q) {
r = r.where(q);
}
return r;
}
}, {
key: 'create',
value: function create() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var edge = new (_bind.apply(this, [null].concat(args)))();
return edge.save();
}
}]);
return E;
})();
exports['default'] = E;
module.exports = exports['default'];