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.0.12 to 1.0.13

5

History.md
1.0.13 / 2011-02-16
===================
* Fixed embedded documents saving.
1.0.12 / 2011-02-14

@@ -3,0 +8,0 @@ ===================

2

lib/mongoose/index.js

@@ -256,3 +256,3 @@

exports.version = '1.0.12';
exports.version = '1.0.13';

@@ -259,0 +259,0 @@ /**

@@ -154,3 +154,5 @@

// normalize MongooseArray or MongooseNumber
if (type._path)
if (type instanceof MongooseArray) {
type = type.toObject();
} else if (type._path)
type = type.valueOf();

@@ -157,0 +159,0 @@

@@ -77,2 +77,16 @@

/**
* Returns an Array and converts any Document
* members toObject.
*
* @return {Array}
* @api public
*/
MongooseDocumentArray.prototype.toObject = function () {
return this.map( function (doc) {
return doc.toObject();
});
};
/**
* Module exports.

@@ -79,0 +93,0 @@ */

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

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

@@ -163,2 +163,24 @@

'test a model that defaults an Array attributes to an empty array': function () {
var db = start()
, DefaultZeroCardArraySchema = new Schema({
arr: {type: Array, cast: String, default: []}
});
mongoose.model('DefaultZeroCardArray', DefaultZeroCardArraySchema);
var DefaultZeroCardArray = db.model('DefaultZeroCardArray', collection);
var arr = new DefaultZeroCardArray();
arr.get('arr').should.have.length(0);
arr.arr.should.have.length(0);
db.close();
},
'test that arrays auto-default to the empty array': function () {
var db = start()
, BlogPost = db.model('BlogPost', collection);
var post = new BlogPost();
post.numbers.should.have.length(0);
db.close();
},
'test instantiating a model with a hash that maps to at least 1 null value': function () {

@@ -1552,2 +1574,25 @@ var db = start()

},
// GH-255
'test updating an embedded document in an embedded array': function () {
var db = start()
, BlogPost = db.model('BlogPost', collection);
BlogPost.create({comments: [{title: 'woot'}]}, function (err, post) {
should.strictEqual(err, null);
BlogPost.findById(post._id, function (err, found) {
should.strictEqual(err, null);
found.comments[0].title.should.equal('woot');
found.comments[0].title = 'notwoot';
found.save( function (err) {
should.strictEqual(err, null);
BlogPost.findById(found._id, function (err, updated) {
db.close();
should.strictEqual(err, null);
updated.comments[0].title.should.equal('notwoot');
});
});
});
});
},
'test filtering an embedded array by the id shortcut function': function () {

@@ -1554,0 +1599,0 @@ var db = start()

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