Socket
Socket
Sign inDemoInstall

mongoose

Package Overview
Dependencies
Maintainers
0
Versions
883
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 1.1.5 to 1.1.6

lib/mongoose/schema/.array.js.swp

11

History.md
1.1.6 / 2011-03-22
==================
* Only doValidate when path exists in Schema [aheckmann]
* Allow function defaults for Array types [aheckmann]
* Fix validation hang [aheckmann]
* Fix setting of isRequired of SchemaType [aheckmann]
* Fix SchemaType#required(false) filter [aheckmann]
* More backwards compatibility [aheckmann]
* More tests [aheckmann]
1.1.5 / 2011-03-14

@@ -3,0 +14,0 @@ ==================

14

lib/mongoose/document.js

@@ -122,12 +122,10 @@

if (obj[i] !== null && obj[i] !== undefined) {
var schema = self.schema.path(path);
if (schema)
if (schema) {
self.try(function(){
doc[i] = schema.cast(obj[i], self);
});
else
} else {
doc[i] = obj[i];
}
}
// mark as hydrated

@@ -381,3 +379,6 @@ self.activePaths.init(path);

process.nextTick(function(){
self.schema.path(path).doValidate(self.getValue(path), function(err){
var p = self.schema.path(path);
if (!p) return --total || next();
p.doValidate(self.getValue(path), function(err){
if (err) {

@@ -389,2 +390,3 @@ didErr = true;

}, self);
});

@@ -391,0 +393,0 @@ validating[path] = true;

@@ -284,3 +284,3 @@

exports.version = '1.1.5';
exports.version = '1.1.6';

@@ -287,0 +287,0 @@ /**

@@ -34,7 +34,13 @@ /**

var self = this
, defaultArr;
, defaultArr
, fn;
if (this.defaultValue) defaultArr = this.defaultValue;
if (this.defaultValue) {
defaultArr = this.defaultValue;
fn = 'function' == typeof defaultArr;
}
this.default(function(){
return new MongooseArray(defaultArr || [], self.path, this);
var arr = fn ? defaultArr() : defaultArr || [];
return new MongooseArray(arr, self.path, this);
});

@@ -41,0 +47,0 @@ };

@@ -131,11 +131,17 @@

SchemaType.prototype.required = function(required){
var checkRequired = this.checkRequired.bind(this);
this.isRequired = true;
var self = this;
function __checkRequired (v) {
return self.checkRequired(v);
}
if (false === required){
this.isRequired = false;
this.validators = this.validators.filter(function(v){
return v[0] !== checkRequired;
return v[0].name !== '__checkRequired';
});
} else
this.validators.push([checkRequired, 'required']);
} else {
this.isRequired = true;
this.validators.push([__checkRequired, 'required']);
}

@@ -142,0 +148,0 @@ return this;

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

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

@@ -268,2 +268,3 @@ Mongoose 1.0

- Brian Noguchi - [bnoguchi](https://github.com/bnoguchi)
- Aaron Heckmann - [aheckmann](https://github.com/aheckmann)

@@ -270,0 +271,0 @@ ## License

@@ -110,2 +110,13 @@

'test that an empty find does not hang': function () {
var db = start()
, BlogPostB = db.model('BlogPostB', collection)
function fn () {
db.close();
};
BlogPostB.find({}, fn);
},
'test that a query is executed when a callback is passed': function () {

@@ -261,2 +272,4 @@ var db = start()

var pending = 2;
BlogPostB.findById(post.get('_id'), function (err, doc) {

@@ -266,4 +279,10 @@ should.strictEqual(err, null);

doc.get('title').should.eql(title);
--pending || db.close();
});
db.close();
BlogPostB.findById(post.get('_id').toHexString(), function (err, doc) {
should.strictEqual(err, null);
doc.should.be.an.instanceof(BlogPostB);
doc.get('title').should.eql(title);
--pending || db.close();
});

@@ -1060,2 +1079,21 @@ });

'test backwards compatibility with unused values in db': function () {
var db = start()
, BlogPostB = db.model('BlogPostB', collection)
, post = new BlogPostB();
post.collection.insert({ meta: { visitors: 9898, color: 'blue'}}, {}, function (err, b) {
should.strictEqual(err, null);
BlogPostB.findOne({_id: b[0]._id}, function (err, found) {
should.strictEqual(err, null);
found.get('meta.visitors').valueOf().should.eql(9898);
found.save(function (err) {
should.strictEqual(err, null);
db.close();
})
})
})
},
'test streaming cursors with #each': function () {

@@ -1062,0 +1100,0 @@ var db = start()

@@ -18,3 +18,4 @@

, Mixed = SchemaTypes.Mixed
, MongooseNumber = mongoose.Types.Number;
, MongooseNumber = mongoose.Types.Number
, MongooseArray = mongoose.Types.Array;

@@ -124,2 +125,5 @@ /**

simple : { type: String, default: 'a' }
, array : { type: Array, default: [1,2,3,4,5] }
, arrayX : { type: Array, default: 9 }
, arrayFn : { type: Array, default: function () { return [8] } }
, callback : { type: Number, default: function(){

@@ -136,2 +140,7 @@ this.a.should.eql('b');

(+Test.path('callback').getDefault({ a: 'b' })).should.eql(3);
Test.path('array').defaultValue.should.be.a('function');
Test.path('array').getDefault(new TestDocument)[3].should.eql(4);
Test.path('arrayX').getDefault(new TestDocument)[0].should.eql(9);
Test.path('arrayFn').defaultValue.should.be.a('function');
Test.path('arrayFn').getDefault(new TestDocument).should.be.an.instanceof(MongooseArray);
},

@@ -138,0 +147,0 @@

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