Socket
Socket
Sign inDemoInstall

mongoose

Package Overview
Dependencies
Maintainers
4
Versions
888
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

test/.document.test.js.swo

6

History.md
2.0.4 / 2011-08-29
==================
* Fixed; Only send the depopulated ObjectId instead of the entire doc on save (DBRefs)
* Fixed; Properly cast nested array values in Model.update (the data was stored in Mongo incorrectly but recast on document fetch was "fixing" it)
2.0.3 / 2011-08-28

@@ -3,0 +9,0 @@ ==================

3

lib/document.js

@@ -290,5 +290,6 @@

} else {
// TODO - does this handle obj[parts[i]] === 0 ?
if (obj[parts[i]] && obj[parts[i]].constructor === Object) {
obj = obj[parts[i]];
} else if (obj[parts[i]] && Array.isArray(obj[parts[i]])) {
obj = obj[parts[i]];
} else {

@@ -295,0 +296,0 @@ obj = obj[parts[i]] = {};

@@ -287,3 +287,3 @@

exports.version = '2.0.3';
exports.version = '2.0.4';

@@ -290,0 +290,0 @@ /**

@@ -132,10 +132,24 @@

// schema and call path() from there to resolve to
// the correct path type (otherwise, it falsely
// resolves to undefined
var self = this
, subpaths = path.split(/\.\d+\.?/)
.filter(Boolean); // removes empty strings
// the correct path type
var last
, self = this
, subpaths = path.split(/\.(\d+)\.?/)
.filter(Boolean) // removes empty strings
if (subpaths.length > 1) {
return subpaths.reduce(function (val, subpath) {
last = subpaths.length - 1;
return subpaths.reduce(function (val, subpath, i) {
if (val && !val.schema) {
if (i === last && !/\D/.test(subpath) && val instanceof Types.Array) {
return val.caster; // StringSchema, NumberSchema, etc
} else {
return val;
}
}
if (!/\D/.test(subpath)) { // 'path.0.subpath' on path 0
return val;
}
return val ? val.schema.path(subpath)

@@ -142,0 +156,0 @@ : self.path(subpath);

@@ -7,3 +7,3 @@ /**

, CastError = SchemaType.CastError
, ArrayNumberSchema = function () {}
, NumberSchema = require('./number')
, Types = {

@@ -183,2 +183,10 @@ Boolean: require('./boolean')

// subclass number schema to override casting
// to disallow non-numbers being saved
function ArrayNumberSchema (key, options) {
NumberSchema.call(this, key, options);
}
ArrayNumberSchema.prototype.__proto__ = NumberSchema.prototype;
ArrayNumberSchema.prototype.cast = function (value) {

@@ -185,0 +193,0 @@ if (!isNaN(value)) {

@@ -306,3 +306,3 @@

return this.map(function (doc) {
return doc.toObject(options);
return doc._id;
});

@@ -309,0 +309,0 @@ }

{
"name": "mongoose"
, "description": "Mongoose MongoDB ORM"
, "version": "2.0.3"
, "version": "2.0.4"
, "author": "Guillermo Rauch <guillermo@learnboost.com>"

@@ -6,0 +6,0 @@ , "keywords": ["mongodb", "mongoose", "orm", "data", "datastore", "nosql"]

@@ -35,2 +35,3 @@

, oids : [ObjectId]
, numbers : [Number]
, nested : {

@@ -519,3 +520,3 @@ age : Number

delete obj._id;
obj.should.eql({ oids: [] });
obj.should.eql({ numbers: [], oids: [] });
},

@@ -564,4 +565,13 @@

db.close();
},
'setting a positional path does not cast value to array': function () {
var doc = new TestDocument;
doc.init({ numbers: [1,3] });
doc.numbers[0].should.eql(1);
doc.numbers[1].valueOf().should.eql(3);
doc.set('numbers.1', 2);
doc.numbers[0].should.eql(1);
doc.numbers[1].valueOf().should.eql(2);
}
};

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc