Comparing version 0.0.5 to 0.0.6
@@ -37,34 +37,38 @@ 'use strict'; | ||
for (key in dbdata) { | ||
if (dbdata.hasOwnProperty(key)) { | ||
// skip functions | ||
if (typeof dbdata[key] === 'function') { | ||
continue; | ||
} | ||
if (typeof(dbdata) === 'object') { | ||
for (key in dbdata) { | ||
if (dbdata.hasOwnProperty(key)) { | ||
// skip functions | ||
if (typeof dbdata[key] === 'function') { | ||
continue; | ||
} | ||
if (schema.hasOwnProperty(key)) { | ||
// reset | ||
value = undefined; | ||
if (schema.hasOwnProperty(key)) { | ||
// reset | ||
value = undefined; | ||
if (schema[key].$set !== undefined) { | ||
// this is a leaf (contains data) | ||
if (dbdata !== undefined && dbdata !== null) { | ||
value = schema[key].$set(dbdata[key]); | ||
if (schema[key].$set !== undefined) { | ||
// this is a leaf (contains data) | ||
if (dbdata !== undefined && dbdata !== null) { | ||
value = schema[key].$set(dbdata[key]); | ||
} | ||
} else { | ||
// this is a branch (embedded document) | ||
value = initialize(schema[key], dbdata[key], collectionName); | ||
} | ||
} else { | ||
// this is a branch (embedded document) | ||
value = initialize(schema[key], dbdata[key], collectionName); | ||
} | ||
// load or set if the db document contains the key | ||
if (value !== undefined) { | ||
if (data === undefined) { | ||
data = {}; | ||
// load or set if the db document contains the key | ||
if (value !== undefined) { | ||
if (data === undefined) { | ||
data = {}; | ||
} | ||
data[key] = value; | ||
} | ||
data[key] = value; | ||
} else { | ||
console.error(key + ' is not defined in the model [' + collectionName + ']'); | ||
} | ||
} else { | ||
console.error(key + ' is not defined in the model [' + collectionName + ']'); | ||
} | ||
} | ||
} else { | ||
console.error('\'' + dbdata + '\' expected to be an object in the model [' + collectionName + ']'); | ||
} | ||
@@ -898,3 +902,3 @@ | ||
* @param {Object} query Query object as in mongodb documentation | ||
* @param {Object} [options] Query options, such as skip, limit, etc | ||
* @param {Object|Function} [options] Query options, such as skip, limit, etc | ||
* @param {Function} callback Callback function (error, model) with the result of the operation | ||
@@ -942,3 +946,3 @@ */ | ||
* @param {ObjectID|String} id Either a ObjectId instance or, the function will try to cast it to ObjectId. | ||
* @param {Object} [options] Query options, such as skip, limit, etc | ||
* @param {Object|Function} [options] Query options, such as skip, limit, etc | ||
* @param {Function} callback Callback function (error, model) with the result of the operation | ||
@@ -1028,4 +1032,4 @@ */ | ||
* @param {Object} query MongoDB Query | ||
* @param {Object} [fields] filter the fields to be returned | ||
* @param {Object} [options] options for the query | ||
* @param {Object|Function} [fields] filter the fields to be returned | ||
* @param {Object|Function} [options] options for the query | ||
* options.directObject returns the object directly from mongodb without any ODM decoration | ||
@@ -1083,4 +1087,4 @@ * @param {Function} callback Callback function (error, model) with the result of the operation | ||
* @memberOf Model | ||
* @param {Object} [fields] filter the fields to be returned | ||
* @param {Object} [options] options for the query | ||
* @param {Object|Function} [fields] filter the fields to be returned | ||
* @param {Object|Function} [options] options for the query | ||
* @param {Function} callback Callback function (error, model) with the result of the operation | ||
@@ -1166,4 +1170,4 @@ */ | ||
* @param {ObjectID|ObjectID[]} ids single or array of ObjectId objects | ||
* @param {Object} [fields] filter the fields to be returned | ||
* @param {Object} [options] options for the query | ||
* @param {Object|Function} [fields] filter the fields to be returned | ||
* @param {Object|Function} [options] options for the query | ||
* @param {Function} callback Callback function (error, model) with the result of the operation | ||
@@ -1298,3 +1302,3 @@ */ | ||
* @memberOf Model | ||
* @param {Object} [options] options for the query | ||
* @param {Object|Function} [options] options for the query | ||
* @param {Function} callback Callback function (error, documentId) with the result of the operation | ||
@@ -1340,3 +1344,3 @@ */ | ||
* @memberOf Model | ||
* @param {Object} [options] options for the query | ||
* @param {Object|Function} [options] options for the query | ||
* @param {Function} callback Callback function (error) with the result of the operation | ||
@@ -1423,3 +1427,3 @@ */ | ||
* @param {Object} query Search query of objects to remove | ||
* @param {Object} [options] options for the query | ||
* @param {Object|Function} [options] options for the query | ||
* @param {Function} callback Callback function (error) with the result of the operation | ||
@@ -1426,0 +1430,0 @@ */ |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"engines": { | ||
@@ -11,0 +11,0 @@ "node": ">=0.4.12" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
78848
17
1666