Comparing version 0.2.17 to 0.2.18
@@ -361,9 +361,9 @@ var r = require('rethinkdb'); | ||
query.run({connection: connection, timeFormat: model.thinkyOptions.timeFormat}, function(error, result) { | ||
if (result.toArray != null) { | ||
if (result == null) { | ||
callback(null, null); | ||
} | ||
else if (result.toArray != null) { | ||
wrappedCallback = Model.prototype.callbacks.stream(self, callback); | ||
wrappedCallback(null, result); | ||
} | ||
else if (result == null) { | ||
callback(null, null); | ||
} | ||
else { | ||
@@ -370,0 +370,0 @@ wrappedCallback = Model.prototype.callbacks.document(self, callback); |
@@ -174,2 +174,3 @@ var r = require('rethinkdb'); | ||
newLinkedModels = {}; | ||
newLinkedModels[model.getModel().name] = 1; | ||
} | ||
@@ -189,7 +190,18 @@ else { | ||
if (newLinkedModels[fieldName] != null) { | ||
var otherModelName = otherModel.getModel().name | ||
if ((otherModelName !== model.getModel().name) && (newLinkedModels[otherModelName] >= 1)) { | ||
continue; | ||
} | ||
newLinkedModels[fieldName] = true; | ||
else if ((otherModelName === model.getModel().name) && (newLinkedModels[otherModelName] >= 2)) { | ||
continue; | ||
} | ||
if (newLinkedModels[otherModelName] == null) { | ||
newLinkedModels[otherModelName] = 1 | ||
} | ||
else { | ||
newLinkedModels[otherModelName]++ | ||
} | ||
if (typeof joinClause === 'object') { | ||
@@ -196,0 +208,0 @@ if (type === 'object') { |
{ | ||
"name": "thinky", | ||
"version": "0.2.17", | ||
"version": "0.2.18", | ||
"description": "RethinkDB ORM for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -1169,3 +1169,25 @@ var thinky = require('../lib/index.js'); | ||
it('should work for 1-1 relations for the same model', function(done) { | ||
var Human = thinky.createModel('Human', {id: String, name: String, idFather: String}); | ||
Human.hasOne(Human, 'father', {leftKey: 'idFather', rightKey: 'id'}); | ||
var michel = new Human({name: "Michel"}); | ||
var hung = new Human({name: "Hung"}); | ||
michel['father'] = hung; | ||
michel.save( {saveJoin: true}, function(error, firstResult) { | ||
Human.get(michel.id).getJoin().run(function(error, result) { | ||
should.not.exist(error); | ||
should.exist(result.id); | ||
should.exist(result.idFather); | ||
should.exist(result.father.id); | ||
done(); | ||
}) | ||
}); | ||
}) | ||
it('should work for n-n relations', function(done) { | ||
@@ -1172,0 +1194,0 @@ var Cat = thinky.createModel('Cat', {id: String, name: String}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
954069
20381