mongoose 4.3.3 → 4.3.4

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,3 +1,13 @@
1
+ 4.3.4 / 2015-12-23
2
+ ==================
3
+ * fix: upgrade mongodb driver to 2.1.2 for repl set error #3712 [sansmischevia](https://github.com/sansmischevia)
4
+ * docs: validation docs typo #3709 [ivanmaeder](https://github.com/ivanmaeder)
5
+ * style: remove unused variables #3708 [ChristianMurphy](https://github.com/ChristianMurphy)
6
+ * fix(schema): duck-typing for schemas #3703 [mgcrea](https://github.com/mgcrea)
7
+ * docs: connection sample code issue #3697
8
+ * fix(schema): duck-typing for schemas #3693 [mgcrea](https://github.com/mgcrea)
9
+ * docs: clarify id schema option #3638
10
+
1
11
  4.3.3 / 2015-12-18
2
12
  ==================
3
13
  * fix(connection): properly support 'replSet' as well as 'replset' #3688 [taxilian](https://github.com/taxilian)
package/README.md CHANGED
@@ -41,7 +41,7 @@ $ npm install mongoose
41
41
 
42
42
  ## Stability
43
43
 
44
- The current stable branch is [master](https://github.com/Automattic/mongoose/tree/master). The [3.8.x](https://github.com/Automattic/mongoose/tree/3.8.x) branch contains legacy support for the 3.x release series, which will continue to be actively maintained until September 1, 2015.
44
+ The current stable branch is [master](https://github.com/Automattic/mongoose/tree/master). The [3.8.x](https://github.com/Automattic/mongoose/tree/3.8.x) branch contains legacy support for the 3.x release series, which is no longer under active development as of September 2015. The [3.8.x docs](http://mongoosejs.com/docs/3.8.x/) are still available.
45
45
 
46
46
  ## Overview
47
47
 
@@ -28,7 +28,7 @@ function Document(obj, schema, fields, skipId, skipInit) {
28
28
  return new Document( obj, schema, fields, skipId, skipInit );
29
29
 
30
30
 
31
- if (utils.isObject(schema) && !(schema instanceof Schema)) {
31
+ if (utils.isObject(schema) && !schema.instanceOfSchema) {
32
32
  schema = new Schema(schema);
33
33
  }
34
34
 
package/lib/connection.js CHANGED
@@ -619,13 +619,13 @@ Connection.prototype.model = function(name, schema, collection) {
619
619
  schema = false;
620
620
  }
621
621
 
622
- if (utils.isObject(schema) && !(schema instanceof Schema)) {
622
+ if (utils.isObject(schema) && !schema.instanceOfSchema) {
623
623
  schema = new Schema(schema);
624
624
  }
625
625
 
626
626
  if (this.models[name] && !collection) {
627
627
  // model exists but we are not subclassing with custom collection
628
- if (schema instanceof Schema && schema != this.models[name].schema) {
628
+ if (schema && schema.instanceOfSchema && schema != this.models[name].schema) {
629
629
  throw new MongooseError.OverwriteModelError(name);
630
630
  }
631
631
  return this.models[name];
@@ -634,7 +634,7 @@ Connection.prototype.model = function(name, schema, collection) {
634
634
  var opts = { cache: false, connection: this };
635
635
  var model;
636
636
 
637
- if (schema instanceof Schema) {
637
+ if (schema && schema.instanceOfSchema) {
638
638
  // compile a model
639
639
  model = this.base.model(name, schema, collection, opts);
640
640
 
package/lib/index.js CHANGED
@@ -307,7 +307,7 @@ Mongoose.prototype.model = function(name, schema, collection, skipInit) {
307
307
  schema = false;
308
308
  }
309
309
 
310
- if (utils.isObject(schema) && !(schema instanceof Schema)) {
310
+ if (utils.isObject(schema) && !(schema.instanceOfSchema)) {
311
311
  schema = new Schema(schema);
312
312
  }
313
313
 
@@ -342,7 +342,7 @@ Mongoose.prototype.model = function(name, schema, collection, skipInit) {
342
342
  // connection.model() may be passing a different schema for
343
343
  // an existing model name. in this case don't read from cache.
344
344
  if (this.models[name] && false !== options.cache) {
345
- if (schema instanceof Schema && schema != this.models[name].schema) {
345
+ if (schema && schema.instanceOfSchema && schema != this.models[name].schema) {
346
346
  throw new mongoose.Error.OverwriteModelError(name);
347
347
  }
348
348
 
package/lib/model.js CHANGED
@@ -775,7 +775,7 @@ Model.prototype.model = function model(name) {
775
775
  */
776
776
 
777
777
  Model.discriminator = function discriminator(name, schema) {
778
- if (!(schema instanceof Schema)) {
778
+ if (!(schema && schema.instanceOfSchema)) {
779
779
  throw new Error("You must pass a valid discriminator Schema");
780
780
  }
781
781
 
@@ -240,18 +240,6 @@ function handleArray(val) {
240
240
  });
241
241
  }
242
242
 
243
- function handleBitwiseOperator(val) {
244
- var _this = this;
245
- if (Array.isArray(val)) {
246
- return val.map(function(v) { return _this.cast(v); });
247
- } else if (Buffer.isBuffer(val)) {
248
- return val;
249
- } else {
250
- // Assume trying to cast to number
251
- return this.cast(val);
252
- }
253
- }
254
-
255
243
  SchemaNumber.prototype.$conditionalHandlers =
256
244
  utils.options(SchemaType.prototype.$conditionalHandlers, {
257
245
  '$bitsAllClear': handleBitwiseOperator,
package/lib/schema.js CHANGED
@@ -9,7 +9,6 @@ var utils = require('./utils');
9
9
  var MongooseTypes;
10
10
  var Kareem = require('kareem');
11
11
  var async = require('async');
12
- var PromiseProvider = require('./promise_provider');
13
12
 
14
13
  var IS_QUERY_HOOK = {
15
14
  count: true,
@@ -186,6 +185,7 @@ function idGetter() {
186
185
  */
187
186
  Schema.prototype = Object.create( EventEmitter.prototype );
188
187
  Schema.prototype.constructor = Schema;
188
+ Schema.prototype.instanceOfSchema = true;
189
189
 
190
190
  /**
191
191
  * Default middleware attached to a schema. Cannot be changed.
@@ -243,7 +243,6 @@ Object.defineProperty(Schema.prototype, '_defaultMiddleware', {
243
243
  hook: 'save',
244
244
  isAsync: true,
245
245
  fn: function(next, done) {
246
- var Promise = PromiseProvider.get();
247
246
  var subdocs = this.$__getAllSubdocs();
248
247
 
249
248
  if (!subdocs.length || this.$__preSavingFromParent) {
@@ -540,7 +539,7 @@ Schema.interpretAsType = function(path, obj, options) {
540
539
  ? obj.cast
541
540
  : type[0];
542
541
 
543
- if (cast instanceof Schema) {
542
+ if (cast && cast.instanceOfSchema) {
544
543
  return new MongooseTypes.DocumentArray(path, cast, obj);
545
544
  }
546
545
 
@@ -564,7 +563,7 @@ Schema.interpretAsType = function(path, obj, options) {
564
563
  return new MongooseTypes.Array(path, cast || MongooseTypes.Mixed, obj);
565
564
  }
566
565
 
567
- if (type instanceof Schema) {
566
+ if (type && type.instanceOfSchema) {
568
567
  return new MongooseTypes.Embedded(type, path, obj);
569
568
  }
570
569
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mongoose",
3
3
  "description": "Mongoose MongoDB ODM",
4
- "version": "4.3.3",
4
+ "version": "4.3.4",
5
5
  "author": "Guillermo Rauch <guillermo@learnboost.com>",
6
6
  "keywords": [
7
7
  "mongodb",
@@ -23,7 +23,7 @@
23
23
  "bson": "0.4.19",
24
24
  "hooks-fixed": "1.1.0",
25
25
  "kareem": "1.0.1",
26
- "mongodb": "2.1.0",
26
+ "mongodb": "2.1.2",
27
27
  "mpath": "0.1.1",
28
28
  "mpromise": "0.5.4",
29
29
  "mquery": "1.6.3",