Permalink
Browse files

fixed spec loader and CastError

  • Loading branch information...
1 parent 42d1146 commit d0025dd0c8fae9a3985776bab6be06db4d019dd1 @goulash1971 goulash1971 committed Jul 18, 2011
Showing with 13 additions and 0 deletions.
  1. +11 −0 lib/index.js
  2. +2 −0 lib/types/dbref.js
View
@@ -15,6 +15,16 @@
exports.utils = utils = require("./utils");
+/**
+ * Utility function for typeof array testing
+
+ * @param {Object} the object to be tested as an array
+ * @api private
+ */
+var isArray = Array.isArray || function(obj) {
+ return toString.call(obj) === '[object Array]';
+}
+
/**
* Utility function that will convert an {Array} of arguments into a
* loading specification consiting of a filter {Function} and an
@@ -26,6 +36,7 @@ exports.utils = utils = require("./utils");
*/
var figureLoadSpec = function (args) {
var spec = {filter: function (name) { return true; }, names: []};
+ if (!isArray(args)) args = [args];
if (args.length == 1) {
if (typeof args[0] === 'function')
spec.filter = args[0];
View
@@ -8,6 +8,7 @@
*/
var mongoose = require("mongoose");
+
/**
* Utility function that will cast a single object for a condition
*
@@ -51,6 +52,7 @@ exports.loadType = function (mongoose) {
// The types that are used for schema and models
var SchemaType = mongoose.SchemaType;
var SchemaTypes = mongoose.SchemaTypes;
+ var CastError = SchemaType.CastError;
// The native type used for storage
var dbref = mongoose.mongo.BSONPure.DBRef;

0 comments on commit d0025dd

Please sign in to comment.