@@ -79,6 +79,7 @@ let id = 0;
7979 * - [pluginTags](/docs/guide.html#pluginTags): array of strings - defaults to `undefined`. If set and plugin called with `tags` option, will only apply that plugin to schemas with a matching tag.
8080 *
8181 * #### Options for Nested Schemas:
82+ *
8283 * - `excludeIndexes`: bool - defaults to `false`. If `true`, skip building indexes on this schema's paths.
8384 *
8485 * #### Note:
@@ -233,6 +234,7 @@ Object.defineProperty(Schema.prototype, 'childSchemas', {
233234 * You do not need to interact with this property at all to use mongoose.
234235 *
235236 * #### Example:
237+ *
236238 * const schema = new Schema({});
237239 * schema.virtual('answer').get(() => 42);
238240 *
@@ -272,6 +274,7 @@ Schema.prototype.obj;
272274 * in this schema, and the values are instances of the SchemaType class.
273275 *
274276 * #### Example:
277+ *
275278 * const schema = new Schema({ name: String }, { _id: false });
276279 * schema.paths; // { name: SchemaString { ... } }
277280 *
@@ -290,6 +293,7 @@ Schema.prototype.paths;
290293 * Schema as a tree
291294 *
292295 * #### Example:
296+ *
293297 * {
294298 * '_id' : ObjectId
295299 * , 'nested' : {
@@ -395,8 +399,8 @@ Schema.prototype._clone = function _clone(Constructor) {
395399 * newSchema.path('name'); // SchemaString { ... }
396400 * newSchema.path('age'); // undefined
397401 *
398- * @param {Array } paths list of paths to pick
399- * @param {Object } [options] options to pass to the schema constructor . Defaults to `this.options` if not set.
402+ * @param {String[] } paths List of Paths to pick for the new Schema
403+ * @param {Object } [options] Options to pass to the new Schema Constructor (same as `new Schema(.., Options)`) . Defaults to `this.options` if not set.
400404 * @return {Schema }
401405 * @api public
402406 */
@@ -426,8 +430,8 @@ Schema.prototype.pick = function(paths, options) {
426430/**
427431 * Returns default options for this schema, merged with `options`.
428432 *
429- * @param {Object } options
430- * @return {Object }
433+ * @param {Object } [options] Options to overwrite the default options
434+ * @return {Object } The merged options of `options` and the default options
431435 * @api private
432436 */
433437
@@ -755,6 +759,10 @@ Schema.prototype.clearIndexes = function clearIndexes() {
755759 *
756760 * const schema = new Schema(..);
757761 * schema.methods.init = function () {} // potentially breaking
762+ *
763+ * @property reserved
764+ * @memberOf Schema
765+ * @static
758766 */
759767
760768Schema . reserved = Object . create ( null ) ;
@@ -793,8 +801,8 @@ reserved.collection = 1;
793801 * schema.path('name') // returns a SchemaType
794802 * schema.path('name', Number) // changes the schemaType of `name` to Number
795803 *
796- * @param {String } path
797- * @param {Object } constructor
804+ * @param {String } path The name of the Path to get / set
805+ * @param {Object } [obj] The Type to set the path to, if provided the path will be SET, otherwise the path will be GET
798806 * @api public
799807 */
800808
@@ -1059,6 +1067,7 @@ Object.defineProperty(Schema.prototype, 'base', {
10591067 *
10601068 * @param {String } path
10611069 * @param {Object } obj constructor
1070+ * @param {Object } options
10621071 * @api private
10631072 */
10641073
@@ -1316,6 +1325,7 @@ Schema.prototype.eachPath = function(fn) {
13161325 * Returns an Array of path strings that are required by this schema.
13171326 *
13181327 * #### Example:
1328+ *
13191329 * const s = new Schema({
13201330 * name: { type: String, required: true },
13211331 * age: { type: String, required: true },
@@ -1324,7 +1334,7 @@ Schema.prototype.eachPath = function(fn) {
13241334 * s.requiredPaths(); // [ 'age', 'name' ]
13251335 *
13261336 * @api public
1327- * @param {Boolean } invalidate refresh the cache
1337+ * @param {Boolean } invalidate Refresh the cache
13281338 * @return {Array }
13291339 */
13301340
@@ -1673,8 +1683,14 @@ Schema.prototype.post = function(name) {
16731683 * s.plugin(schema => console.log(schema.path('name').path));
16741684 * mongoose.model('Test', s); // Prints 'name'
16751685 *
1676- * @param {Function } plugin callback
1677- * @param {Object } [opts]
1686+ * Or with Options:
1687+ *
1688+ * const s = new Schema({ name: String });
1689+ * s.plugin((schema, opts) => console.log(opts.text, schema.path('name').path), { text: "Schema Path Name:" });
1690+ * mongoose.model('Test', s); // Prints 'Schema Path Name: name'
1691+ *
1692+ * @param {Function } plugin The Plugin's callback
1693+ * @param {Object } [opts] Options to pass to the plugin
16781694 * @see plugins
16791695 * @api public
16801696 */
@@ -1722,13 +1738,14 @@ Schema.prototype.plugin = function(fn, opts) {
17221738 * });
17231739 *
17241740 * // later
1741+ * const fizz = new Kitty;
17251742 * fizz.purr();
17261743 * fizz.scratch();
17271744 *
17281745 * NOTE: `Schema.method()` adds instance methods to the `Schema.methods` object. You can also add instance methods directly to the `Schema.methods` object as seen in the [guide](/docs/guide.html#methods)
17291746 *
1730- * @param {String|Object } method name
1731- * @param {Function } [fn]
1747+ * @param {String|Object } name The Method Name for a single function, or a Object of "string-function" pairs.
1748+ * @param {Function } [fn] The Function in a single-function definition.
17321749 * @api public
17331750 */
17341751
@@ -1759,10 +1776,21 @@ Schema.prototype.method = function(name, fn, options) {
17591776 * const Drink = mongoose.model('Drink', schema);
17601777 * await Drink.findByName('LaCroix');
17611778 *
1779+ * If a hash of name/fn pairs is passed as the only argument, each name/fn pair will be added as methods.
1780+ *
1781+ * schema.static({
1782+ * findByName: function () {..}
1783+ * , findByCost: function () {..}
1784+ * });
1785+ *
1786+ * const Drink = mongoose.model('Drink', schema);
1787+ * await Drink.findByName('LaCroix');
1788+ * await Drink.findByCost(3);
1789+ *
17621790 * If a hash of name/fn pairs is passed as the only argument, each name/fn pair will be added as statics.
17631791 *
1764- * @param {String|Object } name
1765- * @param {Function } [fn]
1792+ * @param {String|Object } name The Method Name for a single function, or a Object of "string-function" pairs.
1793+ * @param {Function } [fn] The Function in a single-function definition.
17661794 * @api public
17671795 * @see Statics /docs/guide.html#statics
17681796 */
@@ -1785,7 +1813,7 @@ Schema.prototype.static = function(name, fn) {
17851813 *
17861814 * schema.index({ first: 1, last: -1 })
17871815 *
1788- * @param {Object } fields
1816+ * @param {Object } fields The Fields to index, with the order, available values: `1 | -1 | '2d' | '2dsphere' | 'geoHaystack' | 'hashed' | 'text'`
17891817 * @param {Object } [options] Options to pass to [MongoDB driver's `createIndex()` function](https://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#createIndex)
17901818 * @param {String | number } [options.expires=null] Mongoose-specific syntactic sugar, uses [ms](https://www.npmjs.com/package/ms) to convert `expires` option into seconds for the `expireAfterSeconds` in the above link.
17911819 * @api public
@@ -1812,8 +1840,8 @@ Schema.prototype.index = function(fields, options) {
18121840 * schema.set('strict', false); // Sets 'strict' to false
18131841 * schema.set('strict'); // 'false'
18141842 *
1815- * @param {String } key option name
1816- * @param {Object } [value] if not passed, the current option value is returned
1843+ * @param {String } key The name of the option to set the value to
1844+ * @param {Object } [value] The value to set the option to, if not passed, the option will be reset to default
18171845 * @see Schema ./
18181846 * @api public
18191847 */
@@ -1861,7 +1889,7 @@ Schema.prototype.set = function(key, value, _tags) {
18611889 * schema.set('strict', false);
18621890 * schema.get('strict'); // false
18631891 *
1864- * @param {String } key option name
1892+ * @param {String } key The name of the Option to get the current value for
18651893 * @api public
18661894 * @return {Any } the option's value
18671895 */
@@ -1927,7 +1955,7 @@ Schema.prototype.indexes = function() {
19271955/**
19281956 * Creates a virtual type with the given name.
19291957 *
1930- * @param {String } name
1958+ * @param {String } name The name of the Virtual
19311959 * @param {Object } [options]
19321960 * @param {String|Model } [options.ref] model name or model instance. Marks this as a [populate virtual](/docs/populate.html#populate-virtuals).
19331961 * @param {String|Function } [options.localField] Required for populate virtuals. See [populate virtual docs](/docs/populate.html#populate-virtuals) for more information.
@@ -2045,8 +2073,8 @@ Schema.prototype.virtual = function(name, options) {
20452073/**
20462074 * Returns the virtual type with the given `name`.
20472075 *
2048- * @param {String } name
2049- * @return {VirtualType }
2076+ * @param {String } name The name of the Virtual to get
2077+ * @return {VirtualType|null }
20502078 */
20512079
20522080Schema . prototype . virtualpath = function ( name ) {
@@ -2063,7 +2091,13 @@ Schema.prototype.virtualpath = function(name) {
20632091 * schema.path('name'); // Undefined
20642092 * schema.path('age'); // SchemaNumber { ... }
20652093 *
2066- * @param {String|Array } path
2094+ * Or as a Array:
2095+ *
2096+ * schema.remove(['name', 'age']);
2097+ * schema.path('name'); // Undefined
2098+ * schema.path('age'); // Undefined
2099+ *
2100+ * @param {String|Array } path The Path(s) to remove
20672101 * @return {Schema } the Schema instance
20682102 * @api public
20692103 */
@@ -2151,7 +2185,7 @@ function _deletePath(schema, name) {
21512185 * userSchema.loadClass(UserClass);
21522186 * ```
21532187 *
2154- * @param {Function } model
2188+ * @param {Function } model The Class to load
21552189 * @param {Boolean } [virtualsOnly] if truthy, only pulls virtuals from the class, not methods or statics
21562190 */
21572191Schema . prototype . loadClass = function ( model , virtualsOnly ) {
0 commit comments