mongoose 3.6.19 → 3.6.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/History.md CHANGED
@@ -1,5 +1,13 @@
1
1
 
2
- 3.6.19 / 2013-09-04
2
+ 3.6.20 (stable) / 2013-09-23
3
+ ===================
4
+
5
+ * fixed; repopulating modified populated paths #1697
6
+ * fixed; doc.equals w/ _id false #1687
7
+ * fixed; strict mode warning #1686
8
+ * docs; near/nearSphere
9
+
10
+ 3.6.19 (stable) / 2013-09-04
3
11
  ==================
4
12
 
5
13
  * fixed; population field selection w/ strings #1669
package/lib/document.js CHANGED
@@ -1591,7 +1591,7 @@ Document.prototype.toString = Document.prototype.inspect;
1591
1591
  Document.prototype.equals = function (doc) {
1592
1592
  var tid = this.get('_id');
1593
1593
  var docid = doc.get('_id');
1594
- return tid.equals
1594
+ return tid && tid.equals
1595
1595
  ? tid.equals(docid)
1596
1596
  : tid === docid;
1597
1597
  }
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ 'use strict';
1
2
 
2
3
  /*!
3
4
  * Module dependencies.
@@ -16,7 +17,7 @@ var Schema = require('./schema')
16
17
  , utils = require('./utils')
17
18
  , format = utils.toCollectionName
18
19
  , mongodb = require('mongodb')
19
- , package = require(__dirname + '/../package.json')
20
+ , pkg = require('../package.json')
20
21
 
21
22
  /*!
22
23
  * Warn users if they are running an unstable release.
@@ -25,9 +26,9 @@ var Schema = require('./schema')
25
26
  * environment variable.
26
27
  */
27
28
 
28
- if (package.publishConfig && 'unstable' == package.publishConfig.tag) {
29
+ if (pkg.publishConfig && 'unstable' == pkg.publishConfig.tag) {
29
30
  if (!process.env.MONGOOSE_DISABLE_STABILITY_WARNING) {
30
- console.log('\033[33m');
31
+ console.log('\u001b[33m');
31
32
  console.log('##############################################################');
32
33
  console.log('#');
33
34
  console.log('# !!! MONGOOSE WARNING !!!');
@@ -37,7 +38,7 @@ if (package.publishConfig && 'unstable' == package.publishConfig.tag) {
37
38
  console.log('# DO NOT run this in production.');
38
39
  console.log('#');
39
40
  console.log('##############################################################');
40
- console.log('\033[0m');
41
+ console.log('\u001b[0m');
41
42
  }
42
43
  }
43
44
 
@@ -468,7 +469,7 @@ Mongoose.prototype.Connection = Connection;
468
469
  * @api public
469
470
  */
470
471
 
471
- Mongoose.prototype.version = package.version;
472
+ Mongoose.prototype.version = pkg.version;
472
473
 
473
474
  /**
474
475
  * The Mongoose constructor
package/lib/model.js CHANGED
@@ -1812,6 +1812,8 @@ function populateDocs (docs, options, cb) {
1812
1812
  }
1813
1813
 
1814
1814
  if (ret) {
1815
+ ret = convertTo_id(ret);
1816
+
1815
1817
  // previously we always assigned this even if the document had no _id
1816
1818
  options._docs[id] = Array.isArray(ret)
1817
1819
  ? ret.slice()
@@ -1905,6 +1907,28 @@ function populateDocs (docs, options, cb) {
1905
1907
  });
1906
1908
  }
1907
1909
 
1910
+ /*!
1911
+ * Retrieve the _id of `val` if a Document or Array of Documents.
1912
+ *
1913
+ * @param {Array|Document|Any} val
1914
+ * @return {Array|Document|Any}
1915
+ */
1916
+
1917
+ function convertTo_id (val) {
1918
+ if (val instanceof Model) return val._id;
1919
+
1920
+ if (Array.isArray(val)) {
1921
+ for (var i = 0; i < val.length; ++i) {
1922
+ if (val[i] instanceof Model) {
1923
+ val[i] = val[i]._id;
1924
+ }
1925
+ }
1926
+ return val;
1927
+ }
1928
+
1929
+ return val;
1930
+ }
1931
+
1908
1932
  /*!
1909
1933
  * Assigns documents returned from a population query back
1910
1934
  * to the original document path.
package/lib/query.js CHANGED
@@ -865,8 +865,13 @@ Query.prototype.and = function and (array) {
865
865
  /**
866
866
  * Specifies a `$near` condition
867
867
  *
868
+ * query.near('loc', [10, 20])
869
+ * query.near([10, 20])
870
+ *
871
+ * _NOTE: does not currently support GeoJSON._
872
+ *
868
873
  * @param {String} path
869
- * @param {Number} val
874
+ * @param {Array} val
870
875
  * @return {Query} this
871
876
  * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
872
877
  * @see $near http://docs.mongodb.org/manual/reference/operator/near/
@@ -891,8 +896,13 @@ Query.prototype.near = function (path, val) {
891
896
  /**
892
897
  * Specifies a `$nearSphere` condition.
893
898
  *
899
+ * query.nearSphere('loc', [10, 20])
900
+ * query.nearSphere([10, 20])
901
+ *
902
+ * _NOTE: does not currently support GeoJSON._
903
+ *
894
904
  * @param {String} path
895
- * @param {Object} val
905
+ * @param {Array} val
896
906
  * @return {Query} this
897
907
  * @see http://www.mongodb.org/display/DOCS/Geospatial+Indexing
898
908
  * @see $nearSphere http://docs.mongodb.org/manual/reference/operator/nearSphere/
@@ -0,0 +1,41 @@
1
+
2
+ /*!
3
+ * Module dependencies.
4
+ */
5
+
6
+ var SchemaType = require('../schematype')
7
+ , CastError = SchemaType.CastError
8
+ , errorMessages = require('../error').messages
9
+ , utils = require('../utils')
10
+ , Document
11
+
12
+ /**
13
+ * EmbeddedDocument SchemaType constructor.
14
+ *
15
+ * @param {String} key
16
+ * @param {Object} options
17
+ * @inherits SchemaType
18
+ * @api private
19
+ */
20
+
21
+ function SchemaEmbedded (key, options, EmbeddedDoc, parentArray) {
22
+ SchemaType.call(this, key, options, 'EmbeddedDocument');
23
+ this.EmbeddedDoc = EmbeddedDoc;
24
+ this.parentArray = parentArray;
25
+ };
26
+
27
+ /*!
28
+ * Inherits from SchemaType.
29
+ */
30
+
31
+ SchemaEmbedded.prototype.__proto__ = SchemaType.prototype;
32
+
33
+ SchemaEmbedded.prototype.cast = function (value, doc, init) {
34
+ return new this.EmbeddedDoc(value, this.parentArray);
35
+ }
36
+
37
+ /*!
38
+ * Module exports.
39
+ */
40
+
41
+ module.exports = SchemaEmbedded;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose"
3
3
  , "description": "Elegant MongoDB object modeling for Node.js"
4
- , "version": "3.6.19"
4
+ , "version": "3.6.20"
5
5
  , "author": "Guillermo Rauch <guillermo@learnboost.com>"
6
6
  , "keywords": ["mongodb", "document", "model", "schema", "database", "odm", "data", "datastore", "query", "nosql", "orm", "db"]
7
7
  , "dependencies": {
package/747-todo DELETED
@@ -1,15 +0,0 @@
1
-
2
- X merge tests
3
- X update tests with new error messages
4
- X add inline documentation
5
- X add website documentation
6
- X add website documentation around custom validators using new {TEMPLATING} helpers
7
-
8
- -- docs --
9
-
10
- - calling doc#invalidate()
11
- - no longer uses the error message argument for the ValidationError "type" property
12
- - the error message argument will be used as is for the error message. {TEMPLATING} is supported
13
- - for custom validators, the error `type` property will always be set to "user defined"
14
-
15
- Any other changes??
package/createtest DELETED
@@ -1,20 +0,0 @@
1
- #!/bin/bash
2
- # copy our goosetest.js to another filename passed on the cmd line
3
- # and replace all occurances of {NAME} with the filename too.
4
- test $# -ne 1 && echo "usage: goosetest scriptname" && exit 0;
5
-
6
- # EDITOR must be set
7
- test -e $EDITOR && echo "Please set your EDITOR environment variable" && exit 0;
8
-
9
- # get the directory of ourself
10
- DIR="`dirname \"$0\"`"
11
-
12
- # does the file they are about to create exist?
13
- if test -e $1.js; then
14
- # do not overwrite. open for editing.
15
- $EDITOR $1.js
16
- else
17
- # create
18
- cat "$DIR/../goosetest.js" | sed "s/{NAME}/$1/g" >> $1.js
19
- $EDITOR $1.js
20
- fi