Skip to content

Commit

Permalink
fixed; finding by Date now works as expected
Browse files Browse the repository at this point in the history
closes #336
  • Loading branch information
aheckmann committed Apr 28, 2011
1 parent 442eae7 commit b5567c3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/mongoose/schema/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,18 @@ SchemaDate.prototype.$conditionalHandlers = {

SchemaDate.prototype.castForQuery = function ($conditional, val) {
var handler;
if (arguments.length === 2) {
handler = this.$conditionalHandlers[$conditional];
if (!handler)
throw new Error("Can't use " + $conditional + " with Date.");
return handler.call(this, val);
} else {
val = $conditional;
this.cast(val);

if (2 !== arguments.length) {
return this.cast($conditional);
}

handler = this.$conditionalHandlers[$conditional];

if (!handler) {
throw new Error("Can't use " + $conditional + " with Date.");
}

return handler.call(this, val);
};

/**
Expand Down

1 comment on commit b5567c3

@jchaney
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w00t! ty

Please sign in to comment.