Skip to content

Commit 1e32e83

Browse files
committed
add jsdoc to schema/map re: code review comment
1 parent 38fab4a commit 1e32e83

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

lib/schema/map.js

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,48 @@ const MongooseError = require('../error/mongooseError');
1212
const Schema = require('../schema');
1313
const utils = require('../utils');
1414

15-
/*!
16-
* ignore
17-
*/
18-
1915
class SchemaMap extends SchemaType {
16+
/**
17+
* Map SchemaType constructor.
18+
*
19+
* @param {String} path
20+
* @param {Object} options
21+
* @param {Object} schemaOptions
22+
* @param {Schema} parentSchema
23+
* @inherits SchemaType
24+
* @api public
25+
*/
26+
2027
constructor(key, options, schemaOptions, parentSchema) {
2128
super(key, options, 'Map', parentSchema);
2229
this.$isSchemaMap = true;
2330
// Create the nested schema type for the map values
2431
this._createNestedSchemaType(parentSchema, key, options, schemaOptions);
2532
}
2633

34+
/**
35+
* Sets a default option for all Map instances.
36+
*
37+
* @param {String} option The option you'd like to set the value for
38+
* @param {Any} value value for option
39+
* @return {undefined}
40+
* @function set
41+
* @static
42+
* @api public
43+
*/
44+
2745
set(option, value) {
2846
return SchemaType.set(option, value);
2947
}
3048

49+
/**
50+
* Casts to Map
51+
*
52+
* @param {Object} value
53+
* @param {Object} model this value is optional
54+
* @api private
55+
*/
56+
3157
cast(val, doc, init, prev, options) {
3258
if (val instanceof MongooseMap) {
3359
return val;
@@ -70,6 +96,12 @@ class SchemaMap extends SchemaType {
7096
return new MongooseMap(val, path, doc, this.$__schemaType, options);
7197
}
7298

99+
/**
100+
* Creates a copy of this map schema type.
101+
*
102+
* @api private
103+
*/
104+
73105
clone() {
74106
const schematype = super.clone();
75107

@@ -81,7 +113,10 @@ class SchemaMap extends SchemaType {
81113

82114
/**
83115
* Returns the embedded schema type (i.e. the `.$*` path)
116+
*
117+
* @api public
84118
*/
119+
85120
getEmbeddedSchemaType() {
86121
return this.$__schemaType;
87122
}
@@ -105,6 +140,12 @@ class SchemaMap extends SchemaType {
105140
return result;
106141
}
107142

143+
/**
144+
* Returns the auto encryption type for this schema type.
145+
*
146+
* @api public
147+
*/
148+
108149
autoEncryptionType() {
109150
return 'object';
110151
}
@@ -116,6 +157,7 @@ class SchemaMap extends SchemaType {
116157
*
117158
* @api public
118159
*/
160+
119161
SchemaMap.schemaName = 'Map';
120162

121163
SchemaMap.prototype.OptionsConstructor = SchemaMapOptions;

0 commit comments

Comments
 (0)