Comparing version 1.16.10 to 1.16.11
@@ -1720,3 +1720,28 @@ var schemaUtil = require(__dirname+'/schema.js'); | ||
/** | ||
* Have the model emit 'retrieved' with the current document and | ||
* recurse to have all joined models do the same. | ||
*/ | ||
Document.prototype._emitRetrieve = function() { | ||
var self = this; | ||
self.getModel().emit('retrieved', self); | ||
util.loopKeys(self._getModel()._joins, function(joins, key) { | ||
var join = joins[key]; | ||
if ((joins[key].type === 'hasOne') || (joins[key].type === 'belongsTo')) { | ||
if ((self[key] != null) && (typeof self[key]._emitRetrieve === 'function')) { | ||
self[key]._emitRetrieve(); | ||
} | ||
} | ||
else if ((joins[key].type === 'hasMany') || (joins[key].type === 'hasAndBelongsToMany')) { | ||
if (Array.isArray(self[key])) { | ||
for(var i=0; i<self[key].length; i++) { | ||
if (typeof self[key][i]._emitRetrieve === 'function') { | ||
self[key][i]._emitRetrieve(); | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
} | ||
module.exports = Document; |
@@ -1140,3 +1140,3 @@ var util = require(__dirname+'/util.js'); | ||
self.emit('retrieved', newDoc); | ||
newDoc._emitRetrieve(); | ||
@@ -1178,3 +1178,3 @@ promise = util.hook({ | ||
self.emit('retrieved', newDoc); | ||
newDoc._emitRetrieve(); | ||
@@ -1229,3 +1229,3 @@ promise = util.hook({ | ||
self.emit('retrieved', newDoc); | ||
newDoc._emitRetrieve(); | ||
@@ -1232,0 +1232,0 @@ promise = util.hook({ |
@@ -201,2 +201,3 @@ var arrayPrefix = "__array" | ||
|| type.isArray(schema) | ||
|| type.isAny(schema) | ||
|| type.isVirtual(schema)){ // Unknown type | ||
@@ -203,0 +204,0 @@ // Nothing to do here |
@@ -212,2 +212,12 @@ var schema = require(__dirname+'/../schema.js'); | ||
/** | ||
* Check if the first argument is a TypeAny object or not | ||
* @param {Object} obj The object to check against TypeAny. | ||
* @return {boolean} | ||
*/ | ||
Type.prototype.isAny = function(obj) { | ||
return obj instanceof TypeAny; | ||
} | ||
module.exports = new Type(); |
{ | ||
"name": "thinky", | ||
"version": "1.16.10", | ||
"version": "1.16.11", | ||
"description": "RethinkDB ORM for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/thinky.js", |
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
211625
5755