Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Jan 15, 2025
1 parent 672f74e commit 32cf963
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 130 deletions.
94 changes: 47 additions & 47 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,16 @@ function aliasFields(schema, paths) {

schema.
virtual(a).
get((function (p) {
return function () {
get((function(p) {
return function() {
if (typeof this.get === 'function') {
return this.get(p);
}
return this[p];
};
})(prop)).
set((function (p) {
return function (v) {
set((function(p) {
return function(v) {
return this.$set(p, v);
};
})(prop));
Expand All @@ -238,16 +238,16 @@ function aliasFields(schema, paths) {

schema.
virtual(alias).
get((function (p) {
return function () {
get((function(p) {
return function() {
if (typeof this.get === 'function') {
return this.get(p);
}
return this[p];
};
})(prop)).
set((function (p) {
return function (v) {
set((function(p) {
return function(v) {
return this.$set(p, v);
};
})(prop));
Expand Down Expand Up @@ -390,7 +390,7 @@ Schema.prototype.tree;
* @instance
*/

Schema.prototype.clone = function () {
Schema.prototype.clone = function() {
const s = this._clone();

// Bubble up `init` for backwards compat
Expand All @@ -410,7 +410,7 @@ Schema.prototype._clone = function _clone(Constructor) {
s.base = this.base;
s.obj = this.obj;
s.options = clone(this.options);
s.callQueue = this.callQueue.map(function (f) { return f; });
s.callQueue = this.callQueue.map(function(f) { return f; });
s.methods = clone(this.methods);
s.methodOptions = clone(this.methodOptions);
s.statics = clone(this.statics);
Expand Down Expand Up @@ -493,7 +493,7 @@ Schema.prototype._clone = function _clone(Constructor) {
* @api public
*/

Schema.prototype.pick = function (paths, options) {
Schema.prototype.pick = function(paths, options) {
const newSchema = new Schema({}, options || this.options);
if (!Array.isArray(paths)) {
throw new MongooseError('Schema#pick() only accepts an array argument, ' +
Expand Down Expand Up @@ -549,7 +549,7 @@ Schema.prototype.pick = function (paths, options) {
* @api public
*/

Schema.prototype.omit = function (paths, options) {
Schema.prototype.omit = function(paths, options) {
const newSchema = new Schema(this, options || this.options);
if (!Array.isArray(paths)) {
throw new MongooseError(
Expand Down Expand Up @@ -579,7 +579,7 @@ Schema.prototype.omit = function (paths, options) {
* @api private
*/

Schema.prototype.defaultOptions = function (options) {
Schema.prototype.defaultOptions = function(options) {
this._userProvidedOptions = options == null ? {} : clone(options);
const baseOptions = this.base && this.base.options || {};
const strict = 'strict' in baseOptions ? baseOptions.strict : true;
Expand Down Expand Up @@ -656,7 +656,7 @@ Schema.prototype.defaultOptions = function (options) {
* @return {Schema} the Schema instance
* @api public
*/
Schema.prototype.discriminator = function (name, schema, options) {
Schema.prototype.discriminator = function(name, schema, options) {
this._applyDiscriminators = this._applyDiscriminators || new Map();
this._applyDiscriminators.set(name, { schema, options });

Expand All @@ -668,7 +668,7 @@ Schema.prototype.discriminator = function (name, schema, options) {
* options.
*/

Schema.prototype._defaultToObjectOptions = function (json) {
Schema.prototype._defaultToObjectOptions = function(json) {
const path = json ? 'toJSON' : 'toObject';
if (this._defaultToObjectOptionsMap && this._defaultToObjectOptionsMap[path]) {
return this._defaultToObjectOptionsMap[path];
Expand Down Expand Up @@ -1133,7 +1133,7 @@ reserved.collection = 1;
* @api public
*/

Schema.prototype.path = function (path, obj) {
Schema.prototype.path = function(path, obj) {
if (obj === undefined) {
if (this.paths[path] != null) {
return this.paths[path];
Expand Down Expand Up @@ -1434,7 +1434,7 @@ Object.defineProperty(Schema.prototype, 'base', {
* @api private
*/

Schema.prototype.interpretAsType = function (path, obj, options) {
Schema.prototype.interpretAsType = function(path, obj, options) {
if (obj instanceof SchemaType) {
if (obj.path === path) {
return obj;
Expand Down Expand Up @@ -1709,7 +1709,7 @@ function createMapNestedSchemaType(schema, schemaType, path, obj, options) {
* @api public
*/

Schema.prototype.eachPath = function (fn) {
Schema.prototype.eachPath = function(fn) {
const keys = Object.keys(this.paths);
const len = keys.length;

Expand Down Expand Up @@ -1790,7 +1790,7 @@ Schema.prototype.indexedPaths = function indexedPaths() {
* @api public
*/

Schema.prototype.pathType = function (path) {
Schema.prototype.pathType = function(path) {
if (this.paths.hasOwnProperty(path)) {
return 'real';
}
Expand Down Expand Up @@ -1833,7 +1833,7 @@ Schema.prototype.pathType = function (path) {
* @api private
*/

Schema.prototype.hasMixedParent = function (path) {
Schema.prototype.hasMixedParent = function(path) {
const subpaths = path.split(/\./g);
path = '';
for (let i = 0; i < subpaths.length; ++i) {
Expand All @@ -1853,7 +1853,7 @@ Schema.prototype.hasMixedParent = function (path) {
* @param {Boolean|Object} timestamps timestamps options
* @api private
*/
Schema.prototype.setupTimestamp = function (timestamps) {
Schema.prototype.setupTimestamp = function(timestamps) {
return setupTimestamps(this, timestamps);
};

Expand Down Expand Up @@ -1951,7 +1951,7 @@ function getPositionalPath(self, path, cleanPath) {
* @api public
*/

Schema.prototype.queue = function (name, args) {
Schema.prototype.queue = function(name, args) {
this.callQueue.push([name, args]);
return this;
};
Expand Down Expand Up @@ -1999,7 +1999,7 @@ Schema.prototype.queue = function (name, args) {
* @api public
*/

Schema.prototype.pre = function (name) {
Schema.prototype.pre = function(name) {
if (name instanceof RegExp) {
const remainingArgs = Array.prototype.slice.call(arguments, 1);
for (const fn of hookNames) {
Expand Down Expand Up @@ -2057,7 +2057,7 @@ Schema.prototype.pre = function (name) {
* @api public
*/

Schema.prototype.post = function (name) {
Schema.prototype.post = function(name) {
if (name instanceof RegExp) {
const remainingArgs = Array.prototype.slice.call(arguments, 1);
for (const fn of hookNames) {
Expand Down Expand Up @@ -2100,7 +2100,7 @@ Schema.prototype.post = function (name) {
* @api public
*/

Schema.prototype.plugin = function (fn, opts) {
Schema.prototype.plugin = function(fn, opts) {
if (typeof fn !== 'function') {
throw new Error('First param to `schema.plugin()` must be a function, ' +
'got "' + (typeof fn) + '"');
Expand Down Expand Up @@ -2155,7 +2155,7 @@ Schema.prototype.plugin = function (fn, opts) {
* @api public
*/

Schema.prototype.method = function (name, fn, options) {
Schema.prototype.method = function(name, fn, options) {
if (typeof name !== 'string') {
for (const i in name) {
this.methods[i] = name[i];
Expand Down Expand Up @@ -2201,7 +2201,7 @@ Schema.prototype.method = function (name, fn, options) {
* @see Statics https://mongoosejs.com/docs/guide.html#statics
*/

Schema.prototype.static = function (name, fn) {
Schema.prototype.static = function(name, fn) {
if (typeof name !== 'string') {
for (const i in name) {
this.statics[i] = name[i];
Expand All @@ -2226,7 +2226,7 @@ Schema.prototype.static = function (name, fn) {
* @api public
*/

Schema.prototype.index = function (fields, options) {
Schema.prototype.index = function(fields, options) {
fields || (fields = {});
options || (options = {});

Expand Down Expand Up @@ -2272,7 +2272,7 @@ Schema.prototype.index = function (fields, options) {
* @api public
*/

Schema.prototype.set = function (key, value, tags) {
Schema.prototype.set = function(key, value, tags) {
if (arguments.length === 1) {
return this.options[key];
}
Expand Down Expand Up @@ -2363,7 +2363,7 @@ function _propagateOptionsToImplicitlyCreatedSchemas(baseSchema, options) {
* @return {Any} the option's value
*/

Schema.prototype.get = function (key) {
Schema.prototype.get = function(key) {
return this.options[key];
};

Expand All @@ -2379,10 +2379,10 @@ const indexTypes = '2d 2dsphere hashed text'.split(' ');
*/

Object.defineProperty(Schema, 'indexTypes', {
get: function () {
get: function() {
return indexTypes;
},
set: function () {
set: function() {
throw new Error('Cannot overwrite Schema.indexTypes');
}
});
Expand Down Expand Up @@ -2417,7 +2417,7 @@ Object.defineProperty(Schema, 'indexTypes', {
* @return {Array} list of indexes defined in the schema
*/

Schema.prototype.indexes = function () {
Schema.prototype.indexes = function() {
return getIndexes(this);
};

Expand All @@ -2437,7 +2437,7 @@ Schema.prototype.indexes = function () {
* @return {VirtualType}
*/

Schema.prototype.virtual = function (name, options) {
Schema.prototype.virtual = function(name, options) {
if (name instanceof VirtualType || getConstructorName(name) === 'VirtualType') {
return this.virtual(name.path, name.options);
}
Expand Down Expand Up @@ -2493,7 +2493,7 @@ Schema.prototype.virtual = function (name, options) {
});

virtual.
set(function (v) {
set(function(v) {
if (!this.$$populatedVirtuals) {
this.$$populatedVirtuals = {};
}
Expand Down Expand Up @@ -2539,7 +2539,7 @@ Schema.prototype.virtual = function (name, options) {
' conflicts with a real path in the schema');
}

virtuals[name] = parts.reduce(function (mem, part, i) {
virtuals[name] = parts.reduce(function(mem, part, i) {
mem[part] || (mem[part] = (i === parts.length - 1)
? new VirtualType(options, name)
: {});
Expand All @@ -2565,7 +2565,7 @@ Schema.prototype.virtual = function (name, options) {
* @return {VirtualType|null}
*/

Schema.prototype.virtualpath = function (name) {
Schema.prototype.virtualpath = function(name) {
return this.virtuals.hasOwnProperty(name) ? this.virtuals[name] : null;
};

Expand All @@ -2589,12 +2589,12 @@ Schema.prototype.virtualpath = function (name) {
* @return {Schema} the Schema instance
* @api public
*/
Schema.prototype.remove = function (path) {
Schema.prototype.remove = function(path) {
if (typeof path === 'string') {
path = [path];
}
if (Array.isArray(path)) {
path.forEach(function (name) {
path.forEach(function(name) {
if (this.path(name) == null && !this.nested[name]) {
return;
}
Expand Down Expand Up @@ -2648,7 +2648,7 @@ function _deletePath(schema, name) {
* @api public
*/

Schema.prototype.removeVirtual = function (path) {
Schema.prototype.removeVirtual = function(path) {
if (typeof path === 'string') {
path = [path];
}
Expand Down Expand Up @@ -2710,7 +2710,7 @@ Schema.prototype.removeVirtual = function (path) {
* @param {Function} model The Class to load
* @param {Boolean} [virtualsOnly] if truthy, only pulls virtuals from the class, not methods or statics
*/
Schema.prototype.loadClass = function (model, virtualsOnly) {
Schema.prototype.loadClass = function(model, virtualsOnly) {
// Stop copying when hit certain base classes
if (model === Object.prototype ||
model === Function.prototype ||
Expand All @@ -2723,7 +2723,7 @@ Schema.prototype.loadClass = function (model, virtualsOnly) {

// Add static methods
if (!virtualsOnly) {
Object.getOwnPropertyNames(model).forEach(function (name) {
Object.getOwnPropertyNames(model).forEach(function(name) {
if (name.match(/^(length|name|prototype|constructor|__proto__)$/)) {
return;
}
Expand All @@ -2735,7 +2735,7 @@ Schema.prototype.loadClass = function (model, virtualsOnly) {
}

// Add methods and virtuals
Object.getOwnPropertyNames(model.prototype).forEach(function (name) {
Object.getOwnPropertyNames(model.prototype).forEach(function(name) {
if (name.match(/^(constructor)$/)) {
return;
}
Expand Down Expand Up @@ -2766,7 +2766,7 @@ Schema.prototype.loadClass = function (model, virtualsOnly) {
* ignore
*/

Schema.prototype._getSchema = function (path) {
Schema.prototype._getSchema = function(path) {
const _this = this;
const pathschema = _this.path(path);
const resultPath = [];
Expand Down Expand Up @@ -2873,7 +2873,7 @@ Schema.prototype._getSchema = function (path) {
* ignore
*/

Schema.prototype._getPathType = function (path) {
Schema.prototype._getPathType = function(path) {
const _this = this;
const pathschema = _this.path(path);

Expand All @@ -2883,8 +2883,8 @@ Schema.prototype._getPathType = function (path) {

function search(parts, schema) {
let p = parts.length + 1,
foundschema,
trypath;
foundschema,
trypath;

while (p--) {
trypath = parts.slice(0, p).join('.');
Expand Down
Loading

0 comments on commit 32cf963

Please sign in to comment.