mongoose 6.2.7 → 6.2.10

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.
Files changed (59) hide show
  1. package/.eslintrc.json +35 -26
  2. package/CHANGELOG.md +27 -0
  3. package/dist/browser.umd.js +71 -71
  4. package/lib/aggregate.js +36 -36
  5. package/lib/browser.js +4 -4
  6. package/lib/browserDocument.js +1 -0
  7. package/lib/connection.js +21 -21
  8. package/lib/cursor/AggregationCursor.js +2 -3
  9. package/lib/cursor/QueryCursor.js +3 -3
  10. package/lib/document.js +75 -47
  11. package/lib/error/index.js +2 -2
  12. package/lib/helpers/document/handleSpreadDoc.js +19 -1
  13. package/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
  14. package/lib/helpers/projection/hasIncludedChildren.js +1 -1
  15. package/lib/helpers/query/castFilterPath.js +0 -1
  16. package/lib/index.js +24 -26
  17. package/lib/model.js +141 -136
  18. package/lib/options/SchemaArrayOptions.js +2 -2
  19. package/lib/options/SchemaBufferOptions.js +1 -1
  20. package/lib/options/SchemaDateOptions.js +9 -2
  21. package/lib/options/SchemaDocumentArrayOptions.js +3 -3
  22. package/lib/options/SchemaMapOptions.js +2 -2
  23. package/lib/options/SchemaNumberOptions.js +3 -3
  24. package/lib/options/SchemaObjectIdOptions.js +2 -2
  25. package/lib/options/SchemaStringOptions.js +1 -1
  26. package/lib/options/SchemaSubdocumentOptions.js +2 -2
  27. package/lib/options/SchemaTypeOptions.js +3 -3
  28. package/lib/query.js +253 -225
  29. package/lib/schema/SubdocumentPath.js +6 -3
  30. package/lib/schema/array.js +3 -2
  31. package/lib/schema/boolean.js +4 -4
  32. package/lib/schema/buffer.js +3 -3
  33. package/lib/schema/date.js +7 -7
  34. package/lib/schema/decimal128.js +2 -2
  35. package/lib/schema/documentarray.js +17 -10
  36. package/lib/schema/mixed.js +2 -2
  37. package/lib/schema/number.js +6 -6
  38. package/lib/schema/objectid.js +4 -4
  39. package/lib/schema/string.js +14 -14
  40. package/lib/schema.js +28 -28
  41. package/lib/schematype.js +78 -68
  42. package/lib/types/ArraySubdocument.js +1 -1
  43. package/lib/types/DocumentArray/methods/index.js +2 -2
  44. package/lib/types/array/index.js +1 -1
  45. package/lib/types/array/methods/index.js +14 -12
  46. package/lib/types/buffer.js +1 -1
  47. package/lib/types/decimal128.js +1 -1
  48. package/lib/types/objectid.js +1 -1
  49. package/lib/types/subdocument.js +2 -2
  50. package/lib/virtualtype.js +4 -3
  51. package/package.json +18 -17
  52. package/tools/repl.js +8 -8
  53. package/tools/sharded.js +3 -3
  54. package/types/connection.d.ts +116 -116
  55. package/types/document.d.ts +3 -0
  56. package/types/error.d.ts +2 -2
  57. package/types/index.d.ts +75 -67
  58. package/types/pipelinestage.d.ts +194 -194
  59. package/types/schemaoptions.d.ts +2 -2
@@ -26,7 +26,7 @@ module.exports = SubdocumentPath;
26
26
  * Single nested subdocument SchemaType constructor.
27
27
  *
28
28
  * @param {Schema} schema
29
- * @param {String} key
29
+ * @param {String} path
30
30
  * @param {Object} options
31
31
  * @inherits SchemaType
32
32
  * @api public
@@ -243,6 +243,9 @@ SubdocumentPath.prototype.doValidate = function(value, fn, scope, options) {
243
243
  }
244
244
 
245
245
  if (options && options.skipSchemaValidators) {
246
+ if (!value) {
247
+ return fn(null);
248
+ }
246
249
  return value.validate(fn);
247
250
  }
248
251
 
@@ -280,7 +283,7 @@ SubdocumentPath.prototype.doValidateSync = function(value, scope, options) {
280
283
  /**
281
284
  * Adds a discriminator to this single nested subdocument.
282
285
  *
283
- * ####Example:
286
+ * #### Example:
284
287
  * const shapeSchema = Schema({ name: String }, { discriminatorKey: 'kind' });
285
288
  * const schema = Schema({ shape: shapeSchema });
286
289
  *
@@ -318,7 +321,7 @@ SubdocumentPath.prototype.discriminator = function(name, schema, options) {
318
321
  /**
319
322
  * Sets a default option for all SubdocumentPath instances.
320
323
  *
321
- * ####Example:
324
+ * #### Example:
322
325
  *
323
326
  * // Make all numbers have option `min` equal to 0.
324
327
  * mongoose.Schema.Embedded.set('required', true);
@@ -32,6 +32,7 @@ const emptyOpts = Object.freeze({});
32
32
  * @param {String} key
33
33
  * @param {SchemaType} cast
34
34
  * @param {Object} options
35
+ * @param {Object} schemaOptions
35
36
  * @inherits SchemaType
36
37
  * @api public
37
38
  */
@@ -152,7 +153,7 @@ SchemaArray.defaultOptions = {};
152
153
  /**
153
154
  * Sets a default option for all Array instances.
154
155
  *
155
- * ####Example:
156
+ * #### Example:
156
157
  *
157
158
  * // Make all Array instances have `required` of true by default.
158
159
  * mongoose.Schema.Array.set('required', true);
@@ -185,7 +186,7 @@ SchemaArray._checkRequired = SchemaType.prototype.checkRequired;
185
186
  * Override the function the required validator uses to check whether an array
186
187
  * passes the `required` check.
187
188
  *
188
- * ####Example:
189
+ * #### Example:
189
190
  *
190
191
  * // Require non-empty array to pass `required` check
191
192
  * mongoose.Schema.Types.Array.checkRequired(v => Array.isArray(v) && v.length);
@@ -47,7 +47,7 @@ SchemaBoolean._cast = castBoolean;
47
47
  /**
48
48
  * Sets a default option for all Boolean instances.
49
49
  *
50
- * ####Example:
50
+ * #### Example:
51
51
  *
52
52
  * // Make all booleans have `default` of false.
53
53
  * mongoose.Schema.Boolean.set('default', false);
@@ -68,7 +68,7 @@ SchemaBoolean.set = SchemaType.set;
68
68
  /**
69
69
  * Get/set the function used to cast arbitrary values to booleans.
70
70
  *
71
- * ####Example:
71
+ * #### Example:
72
72
  *
73
73
  * // Make Mongoose cast empty string '' to false.
74
74
  * const original = mongoose.Schema.Boolean.cast();
@@ -148,7 +148,7 @@ SchemaBoolean.prototype.checkRequired = function(value) {
148
148
  /**
149
149
  * Configure which values get casted to `true`.
150
150
  *
151
- * ####Example:
151
+ * #### Example:
152
152
  *
153
153
  * const M = mongoose.model('Test', new Schema({ b: Boolean }));
154
154
  * new M({ b: 'affirmative' }).b; // undefined
@@ -168,7 +168,7 @@ Object.defineProperty(SchemaBoolean, 'convertToTrue', {
168
168
  /**
169
169
  * Configure which values get casted to `false`.
170
170
  *
171
- * ####Example:
171
+ * #### Example:
172
172
  *
173
173
  * const M = mongoose.model('Test', new Schema({ b: Boolean }));
174
174
  * new M({ b: 'nay' }).b; // undefined
@@ -52,7 +52,7 @@ SchemaBuffer._checkRequired = v => !!(v && v.length);
52
52
  /**
53
53
  * Sets a default option for all Buffer instances.
54
54
  *
55
- * ####Example:
55
+ * #### Example:
56
56
  *
57
57
  * // Make all buffers have `required` of true by default.
58
58
  * mongoose.Schema.Buffer.set('required', true);
@@ -74,7 +74,7 @@ SchemaBuffer.set = SchemaType.set;
74
74
  * Override the function the required validator uses to check whether a string
75
75
  * passes the `required` check.
76
76
  *
77
- * ####Example:
77
+ * #### Example:
78
78
  *
79
79
  * // Allow empty strings to pass `required` check
80
80
  * mongoose.Schema.Types.String.checkRequired(v => v != null);
@@ -204,7 +204,7 @@ SchemaBuffer.prototype.cast = function(value, doc, init) {
204
204
  * Sets the default [subtype](https://studio3t.com/whats-new/best-practices-uuid-mongodb/)
205
205
  * for this buffer. You can find a [list of allowed subtypes here](https://api.mongodb.com/python/current/api/bson/binary.html).
206
206
  *
207
- * ####Example:
207
+ * #### Example:
208
208
  *
209
209
  * const s = new Schema({ uuid: { type: Buffer, subtype: 4 });
210
210
  * const M = db.model('M', s);
@@ -52,7 +52,7 @@ SchemaDate._cast = castDate;
52
52
  /**
53
53
  * Sets a default option for all Date instances.
54
54
  *
55
- * ####Example:
55
+ * #### Example:
56
56
  *
57
57
  * // Make all dates have `required` of true by default.
58
58
  * mongoose.Schema.Date.set('required', true);
@@ -73,7 +73,7 @@ SchemaDate.set = SchemaType.set;
73
73
  /**
74
74
  * Get/set the function used to cast arbitrary values to dates.
75
75
  *
76
- * ####Example:
76
+ * #### Example:
77
77
  *
78
78
  * // Mongoose converts empty string '' into `null` for date types. You
79
79
  * // can create a custom caster to disable it.
@@ -122,14 +122,14 @@ SchemaDate._defaultCaster = v => {
122
122
  * This sets the `expireAfterSeconds` index option available in MongoDB >= 2.1.2.
123
123
  * This index type is only compatible with Date types.
124
124
  *
125
- * ####Example:
125
+ * #### Example:
126
126
  *
127
127
  * // expire in 24 hours
128
128
  * new Schema({ createdAt: { type: Date, expires: 60*60*24 }});
129
129
  *
130
130
  * `expires` utilizes the `ms` module from [guille](https://github.com/guille/) allowing us to use a friendlier syntax:
131
131
  *
132
- * ####Example:
132
+ * #### Example:
133
133
  *
134
134
  * // expire in 24 hours
135
135
  * new Schema({ createdAt: { type: Date, expires: '24h' }});
@@ -167,7 +167,7 @@ SchemaDate._checkRequired = v => v instanceof Date;
167
167
  * Override the function the required validator uses to check whether a string
168
168
  * passes the `required` check.
169
169
  *
170
- * ####Example:
170
+ * #### Example:
171
171
  *
172
172
  * // Allow empty strings to pass `required` check
173
173
  * mongoose.Schema.Types.String.checkRequired(v => v != null);
@@ -210,7 +210,7 @@ SchemaDate.prototype.checkRequired = function(value, doc) {
210
210
  /**
211
211
  * Sets a minimum date validator.
212
212
  *
213
- * ####Example:
213
+ * #### Example:
214
214
  *
215
215
  * const s = new Schema({ d: { type: Date, min: Date('1970-01-01') })
216
216
  * const M = db.model('M', s)
@@ -272,7 +272,7 @@ SchemaDate.prototype.min = function(value, message) {
272
272
  /**
273
273
  * Sets a maximum date validator.
274
274
  *
275
- * ####Example:
275
+ * #### Example:
276
276
  *
277
277
  * const s = new Schema({ d: { type: Date, max: Date('2014-01-01') })
278
278
  * const M = db.model('M', s)
@@ -48,7 +48,7 @@ Decimal128._cast = castDecimal128;
48
48
  /**
49
49
  * Sets a default option for all Decimal128 instances.
50
50
  *
51
- * ####Example:
51
+ * #### Example:
52
52
  *
53
53
  * // Make all decimal 128s have `required` of true by default.
54
54
  * mongoose.Schema.Decimal128.set('required', true);
@@ -69,7 +69,7 @@ Decimal128.set = SchemaType.set;
69
69
  /**
70
70
  * Get/set the function used to cast arbitrary values to decimals.
71
71
  *
72
- * ####Example:
72
+ * #### Example:
73
73
  *
74
74
  * // Make Mongoose only refuse to cast numbers as decimal128
75
75
  * const original = mongoose.Schema.Types.Decimal128.cast();
@@ -12,6 +12,7 @@ const SchemaDocumentArrayOptions =
12
12
  const SchemaType = require('../schematype');
13
13
  const discriminator = require('../helpers/model/discriminator');
14
14
  const handleIdOption = require('../helpers/schema/handleIdOption');
15
+ const handleSpreadDoc = require('../helpers/document/handleSpreadDoc');
15
16
  const util = require('util');
16
17
  const utils = require('../utils');
17
18
  const getConstructor = require('../helpers/discriminator/getConstructor');
@@ -29,6 +30,7 @@ let Subdocument;
29
30
  * @param {String} key
30
31
  * @param {Schema} schema
31
32
  * @param {Object} options
33
+ * @param {Object} schemaOptions
32
34
  * @inherits SchemaArray
33
35
  * @api public
34
36
  */
@@ -150,7 +152,7 @@ function _createConstructor(schema, options, baseClass) {
150
152
  /**
151
153
  * Adds a discriminator to this document array.
152
154
  *
153
- * ####Example:
155
+ * #### Example:
154
156
  * const shapeSchema = Schema({ name: String }, { discriminatorKey: 'kind' });
155
157
  * const schema = Schema({ shapes: [shapeSchema] });
156
158
  *
@@ -272,7 +274,7 @@ DocumentArrayPath.prototype.doValidate = function(array, fn, scope, options) {
272
274
  /**
273
275
  * Performs local validations first, then validations on each embedded doc.
274
276
  *
275
- * ####Note:
277
+ * #### Note:
276
278
  *
277
279
  * This method ignores the asynchronous validators.
278
280
  *
@@ -427,13 +429,18 @@ DocumentArrayPath.prototype.cast = function(value, doc, init, prev, options) {
427
429
  const Constructor = getConstructor(this.casterConstructor, rawArray[i]);
428
430
 
429
431
  // Check if the document has a different schema (re gh-3701)
430
- if (rawArray[i].$__ && !(rawArray[i] instanceof Constructor)) {
431
- rawArray[i] = rawArray[i].toObject({
432
- transform: false,
433
- // Special case: if different model, but same schema, apply virtuals
434
- // re: gh-7898
435
- virtuals: rawArray[i].schema === Constructor.schema
436
- });
432
+ if (rawArray[i].$__ != null && !(rawArray[i] instanceof Constructor)) {
433
+ const spreadDoc = handleSpreadDoc(rawArray[i], true);
434
+ if (rawArray[i] !== spreadDoc) {
435
+ rawArray[i] = spreadDoc;
436
+ } else {
437
+ rawArray[i] = rawArray[i].toObject({
438
+ transform: false,
439
+ // Special case: if different model, but same schema, apply virtuals
440
+ // re: gh-7898
441
+ virtuals: rawArray[i].schema === Constructor.schema
442
+ });
443
+ }
437
444
  }
438
445
 
439
446
  if (rawArray[i] instanceof Subdocument) {
@@ -558,7 +565,7 @@ function scopePaths(array, fields, init) {
558
565
  /**
559
566
  * Sets a default option for all DocumentArray instances.
560
567
  *
561
- * ####Example:
568
+ * #### Example:
562
569
  *
563
570
  * // Make all numbers have option `min` equal to 0.
564
571
  * mongoose.Schema.DocumentArray.set('_id', false);
@@ -56,7 +56,7 @@ Mixed.prototype.constructor = Mixed;
56
56
  /**
57
57
  * Attaches a getter for all Mixed paths.
58
58
  *
59
- * ####Example:
59
+ * #### Example:
60
60
  *
61
61
  * // Hide the 'hidden' path
62
62
  * mongoose.Schema.Mixed.get(v => Object.assign({}, v, { hidden: null }));
@@ -76,7 +76,7 @@ Mixed.get = SchemaType.get;
76
76
  /**
77
77
  * Sets a default option for all Mixed instances.
78
78
  *
79
- * ####Example:
79
+ * #### Example:
80
80
  *
81
81
  * // Make all mixed instances have `required` of true by default.
82
82
  * mongoose.Schema.Mixed.set('required', true);
@@ -29,7 +29,7 @@ function SchemaNumber(key, options) {
29
29
  /**
30
30
  * Attaches a getter for all Number instances.
31
31
  *
32
- * ####Example:
32
+ * #### Example:
33
33
  *
34
34
  * // Make all numbers round down
35
35
  * mongoose.Number.get(function(v) { return Math.floor(v); });
@@ -49,7 +49,7 @@ SchemaNumber.get = SchemaType.get;
49
49
  /**
50
50
  * Sets a default option for all Number instances.
51
51
  *
52
- * ####Example:
52
+ * #### Example:
53
53
  *
54
54
  * // Make all numbers have option `min` equal to 0.
55
55
  * mongoose.Schema.Number.set('min', 0);
@@ -76,7 +76,7 @@ SchemaNumber._cast = castNumber;
76
76
  /**
77
77
  * Get/set the function used to cast arbitrary values to numbers.
78
78
  *
79
- * ####Example:
79
+ * #### Example:
80
80
  *
81
81
  * // Make Mongoose cast empty strings '' to 0 for paths declared as numbers
82
82
  * const original = mongoose.Number.cast();
@@ -180,7 +180,7 @@ SchemaNumber.prototype.checkRequired = function checkRequired(value, doc) {
180
180
  /**
181
181
  * Sets a minimum number validator.
182
182
  *
183
- * ####Example:
183
+ * #### Example:
184
184
  *
185
185
  * const s = new Schema({ n: { type: Number, min: 10 })
186
186
  * const M = db.model('M', s)
@@ -234,7 +234,7 @@ SchemaNumber.prototype.min = function(value, message) {
234
234
  /**
235
235
  * Sets a maximum number validator.
236
236
  *
237
- * ####Example:
237
+ * #### Example:
238
238
  *
239
239
  * const s = new Schema({ n: { type: Number, max: 10 })
240
240
  * const M = db.model('M', s)
@@ -288,7 +288,7 @@ SchemaNumber.prototype.max = function(value, message) {
288
288
  /**
289
289
  * Sets a enum validator
290
290
  *
291
- * ####Example:
291
+ * #### Example:
292
292
  *
293
293
  * const s = new Schema({ n: { type: Number, enum: [1, 2, 3] });
294
294
  * const M = db.model('M', s);
@@ -55,7 +55,7 @@ ObjectId.prototype.OptionsConstructor = SchemaObjectIdOptions;
55
55
  /**
56
56
  * Attaches a getter for all ObjectId instances
57
57
  *
58
- * ####Example:
58
+ * #### Example:
59
59
  *
60
60
  * // Always convert to string when getting an ObjectId
61
61
  * mongoose.ObjectId.get(v => v.toString());
@@ -75,7 +75,7 @@ ObjectId.get = SchemaType.get;
75
75
  /**
76
76
  * Sets a default option for all ObjectId instances.
77
77
  *
78
- * ####Example:
78
+ * #### Example:
79
79
  *
80
80
  * // Make all object ids have option `required` equal to true.
81
81
  * mongoose.Schema.ObjectId.set('required', true);
@@ -124,7 +124,7 @@ ObjectId._cast = castObjectId;
124
124
  /**
125
125
  * Get/set the function used to cast arbitrary values to objectids.
126
126
  *
127
- * ####Example:
127
+ * #### Example:
128
128
  *
129
129
  * // Make Mongoose only try to cast length 24 strings. By default, any 12
130
130
  * // char string is a valid ObjectId.
@@ -171,7 +171,7 @@ ObjectId._defaultCaster = v => {
171
171
  * Override the function the required validator uses to check whether a string
172
172
  * passes the `required` check.
173
173
  *
174
- * ####Example:
174
+ * #### Example:
175
175
  *
176
176
  * // Allow empty strings to pass `required` check
177
177
  * mongoose.Schema.Types.String.checkRequired(v => v != null);
@@ -58,7 +58,7 @@ SchemaString._cast = castString;
58
58
  /**
59
59
  * Get/set the function used to cast arbitrary values to strings.
60
60
  *
61
- * ####Example:
61
+ * #### Example:
62
62
  *
63
63
  * // Throw an error if you pass in an object. Normally, Mongoose allows
64
64
  * // objects with custom `toString()` functions.
@@ -104,7 +104,7 @@ SchemaString._defaultCaster = v => {
104
104
  /**
105
105
  * Attaches a getter for all String instances.
106
106
  *
107
- * ####Example:
107
+ * #### Example:
108
108
  *
109
109
  * // Make all numbers round down
110
110
  * mongoose.Schema.String.get(v => v.toLowerCase());
@@ -124,7 +124,7 @@ SchemaString.get = SchemaType.get;
124
124
  /**
125
125
  * Sets a default option for all String instances.
126
126
  *
127
- * ####Example:
127
+ * #### Example:
128
128
  *
129
129
  * // Make all strings have option `trim` equal to true.
130
130
  * mongoose.Schema.String.set('trim', true);
@@ -152,7 +152,7 @@ SchemaString._checkRequired = v => (v instanceof String || typeof v === 'string'
152
152
  * Override the function the required validator uses to check whether a string
153
153
  * passes the `required` check.
154
154
  *
155
- * ####Example:
155
+ * #### Example:
156
156
  *
157
157
  * // Allow empty strings to pass `required` check
158
158
  * mongoose.Schema.Types.String.checkRequired(v => v != null);
@@ -172,7 +172,7 @@ SchemaString.checkRequired = SchemaType.checkRequired;
172
172
  /**
173
173
  * Adds an enum validator
174
174
  *
175
- * ####Example:
175
+ * #### Example:
176
176
  *
177
177
  * const states = ['opening', 'open', 'closing', 'closed']
178
178
  * const s = new Schema({ state: { type: String, enum: states }})
@@ -255,7 +255,7 @@ SchemaString.prototype.enum = function() {
255
255
  /**
256
256
  * Adds a lowercase [setter](https://mongoosejs.com/docs/api.html#schematype_SchemaType-set).
257
257
  *
258
- * ####Example:
258
+ * #### Example:
259
259
  *
260
260
  * const s = new Schema({ email: { type: String, lowercase: true }})
261
261
  * const M = db.model('M', s);
@@ -265,7 +265,7 @@ SchemaString.prototype.enum = function() {
265
265
  *
266
266
  * Note that `lowercase` does **not** affect regular expression queries:
267
267
  *
268
- * ####Example:
268
+ * #### Example:
269
269
  * // Still queries for documents whose `email` matches the regular
270
270
  * // expression /SomeEmail/. Mongoose does **not** convert the RegExp
271
271
  * // to lowercase.
@@ -293,7 +293,7 @@ SchemaString.prototype.lowercase = function(shouldApply) {
293
293
  /**
294
294
  * Adds an uppercase [setter](https://mongoosejs.com/docs/api.html#schematype_SchemaType-set).
295
295
  *
296
- * ####Example:
296
+ * #### Example:
297
297
  *
298
298
  * const s = new Schema({ caps: { type: String, uppercase: true }})
299
299
  * const M = db.model('M', s);
@@ -303,7 +303,7 @@ SchemaString.prototype.lowercase = function(shouldApply) {
303
303
  *
304
304
  * Note that `uppercase` does **not** affect regular expression queries:
305
305
  *
306
- * ####Example:
306
+ * #### Example:
307
307
  * // Mongoose does **not** convert the RegExp to uppercase.
308
308
  * M.find({ email: /an example/ });
309
309
  *
@@ -331,7 +331,7 @@ SchemaString.prototype.uppercase = function(shouldApply) {
331
331
  *
332
332
  * The string value will be [trimmed](https://masteringjs.io/tutorials/fundamentals/trim-string) when set.
333
333
  *
334
- * ####Example:
334
+ * #### Example:
335
335
  *
336
336
  * const s = new Schema({ name: { type: String, trim: true }});
337
337
  * const M = db.model('M', s);
@@ -345,7 +345,7 @@ SchemaString.prototype.uppercase = function(shouldApply) {
345
345
  *
346
346
  * Note that `trim` does **not** affect regular expression queries:
347
347
  *
348
- * ####Example:
348
+ * #### Example:
349
349
  * // Mongoose does **not** trim whitespace from the RegExp.
350
350
  * M.find({ name: / some name / });
351
351
  *
@@ -371,7 +371,7 @@ SchemaString.prototype.trim = function(shouldTrim) {
371
371
  /**
372
372
  * Sets a minimum length validator.
373
373
  *
374
- * ####Example:
374
+ * #### Example:
375
375
  *
376
376
  * const schema = new Schema({ postalCode: { type: String, minlength: 5 })
377
377
  * const Address = db.model('Address', schema)
@@ -427,7 +427,7 @@ SchemaString.prototype.minLength = SchemaString.prototype.minlength;
427
427
  /**
428
428
  * Sets a maximum length validator.
429
429
  *
430
- * ####Example:
430
+ * #### Example:
431
431
  *
432
432
  * const schema = new Schema({ postalCode: { type: String, maxlength: 9 })
433
433
  * const Address = db.model('Address', schema)
@@ -485,7 +485,7 @@ SchemaString.prototype.maxLength = SchemaString.prototype.maxlength;
485
485
  *
486
486
  * Any value that does not pass `regExp`.test(val) will fail validation.
487
487
  *
488
- * ####Example:
488
+ * #### Example:
489
489
  *
490
490
  * const s = new Schema({ name: { type: String, match: /^a/ }})
491
491
  * const M = db.model('M', s)