Comparing version 0.0.6 to 0.0.7
@@ -8,5 +8,5 @@ 'use strict'; | ||
var _database = require('./database'); | ||
var _redink = require('./redink'); | ||
var _database2 = _interopRequireDefault(_database); | ||
var _redink2 = _interopRequireDefault(_redink); | ||
@@ -33,3 +33,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
start: function start() { | ||
db.instance = new _database2.default(schemas, { host: host, name: name }); | ||
db.instance = new _redink2.default(schemas, { host: host, name: name }); | ||
return db.instance.connect(); | ||
@@ -36,0 +36,0 @@ } |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.fetchRelated = exports.fetch = exports.find = exports.archive = exports.update = exports.create = undefined; | ||
exports.fetch = exports.find = exports.archive = exports.update = exports.create = undefined; | ||
@@ -12,21 +12,18 @@ var _dbSingleton = require('./dbSingleton'); | ||
var create = exports.create = function create(type, data) { | ||
return (0, _dbSingleton.db)().instance().create; | ||
return (0, _dbSingleton.db)().instance().create(type, data); | ||
}; /* eslint-disable no-unused-vars */ | ||
var update = exports.update = function update(type, id, data) { | ||
return (0, _dbSingleton.db)().instance().update; | ||
return (0, _dbSingleton.db)().instance().update(type, id, data); | ||
}; | ||
var archive = exports.archive = function archive(type, id) { | ||
return (0, _dbSingleton.db)().instance().delete; | ||
return (0, _dbSingleton.db)().instance().delete(type, id); | ||
}; | ||
var find = exports.find = function find(type) { | ||
var filter = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
return (0, _dbSingleton.db)().instance().find; | ||
return (0, _dbSingleton.db)().instance().find(type, filter); | ||
}; | ||
var fetch = exports.fetch = function fetch(type, id) { | ||
return (0, _dbSingleton.db)().instance().fetch; | ||
return (0, _dbSingleton.db)().instance().fetch(type, id); | ||
}; | ||
var fetchRelated = exports.fetchRelated = function fetchRelated(type, id) { | ||
return (0, _dbSingleton.db)().instance().fetchRelated; | ||
}; | ||
@@ -33,0 +30,0 @@ exports.default = function () { |
@@ -78,3 +78,6 @@ 'use strict'; | ||
if (record[relationship] === null) throw new _httpErrors.Conflict('Cannot post, entity does not exist'); | ||
if (record[relationship] === null) { | ||
throw new _httpErrors.Conflict('Cannot cascade post, entity does not exist but record was created.'); | ||
} | ||
postArray.push.apply(postArray, _toConsumableArray(createPostArray(entity, record[relationship], record.id))); | ||
@@ -81,0 +84,0 @@ } |
@@ -85,2 +85,3 @@ 'use strict'; | ||
var belongsTo = _relationships$key.belongsTo; | ||
var hasOne = _relationships$key.hasOne; | ||
var embedded = _relationships$key.embedded; | ||
@@ -92,6 +93,6 @@ | ||
var table = _rethinkdb2.default.table(hasMany || belongsTo); | ||
var table = _rethinkdb2.default.table(hasMany || belongsTo || hasOne); | ||
var hasFields = record.hasFields(key); | ||
// merge `hasMany` and `belongsTo` relationships | ||
// merge `hasMany`, `belongsTo`, and `hasOne` relationships | ||
return hasMany ? _rethinkdb2.default.branch(hasFields, _defineProperty({}, key, table.getAll(_rethinkdb2.default.args(record(key)('id'))).coerceTo('array').orderBy('id')), {}) : _rethinkdb2.default.branch(hasFields, _defineProperty({}, key, table.get(record(key)('id'))), {}); | ||
@@ -98,0 +99,0 @@ }))); |
@@ -102,6 +102,4 @@ 'use strict'; | ||
var redinkObject = serialized[relationship]; | ||
serialized[relationship] = Array.isArray(redinkObject) ? redinkObject.map(function (obj) { | ||
return obj.id; | ||
}) : redinkObject.id; | ||
if (redinkObject.hasOwnProperty('archived')) delete redinkObject.archived; | ||
serialized[relationship] = redinkObject; | ||
} | ||
@@ -124,5 +122,3 @@ } | ||
if (serialized.hasOwnProperty('meta')) delete serialized.meta; | ||
return serialized; | ||
}; |
{ | ||
"name": "redink", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "RethinkDB ORM", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
5
61147
1673