|
|
@ -1734,9 +1734,7 @@ module.exports = Index; |
|
|
|
* Querying, update |
|
|
|
* Querying, update |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
var dateToJSON = function () { return { $$date: this.getTime() }; } |
|
|
|
var util = require('util') |
|
|
|
, originalDateToJSON = Date.prototype.toJSON |
|
|
|
|
|
|
|
, util = require('util') |
|
|
|
|
|
|
|
, _ = require('underscore') |
|
|
|
, _ = require('underscore') |
|
|
|
, modifierFunctions = {} |
|
|
|
, modifierFunctions = {} |
|
|
|
, lastStepModifierFunctions = {} |
|
|
|
, lastStepModifierFunctions = {} |
|
|
@ -1795,22 +1793,20 @@ function checkObject (obj) { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function serialize (obj) { |
|
|
|
function serialize (obj) { |
|
|
|
var res; |
|
|
|
var res; |
|
|
|
|
|
|
|
|
|
|
|
// Keep track of the fact that this is a Date object
|
|
|
|
|
|
|
|
Date.prototype.toJSON = dateToJSON; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = JSON.stringify(obj, function (k, v) { |
|
|
|
res = JSON.stringify(obj, function (k, v) { |
|
|
|
checkKey(k, v); |
|
|
|
checkKey(k, v); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (v === undefined) { return undefined; } |
|
|
|
|
|
|
|
if (v === null) { return null; } |
|
|
|
|
|
|
|
|
|
|
|
if (typeof v === undefined) { return null; } |
|
|
|
// Hackish way of checking if object is Date (this way it works between execution contexts in node-webkit).
|
|
|
|
if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || v === null) { return v; } |
|
|
|
// We can't use value directly because for dates it is already string in this function (date.toJSON was already called), so we use this
|
|
|
|
|
|
|
|
if (typeof this[k].getTime === 'function') { return { $$date: this[k].getTime() }; } |
|
|
|
|
|
|
|
|
|
|
|
return v; |
|
|
|
return v; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Return Date to its original state
|
|
|
|
|
|
|
|
Date.prototype.toJSON = originalDateToJSON; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|