Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Jan 23, 2025
1 parent a4b4299 commit 57e548b
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 151 deletions.
98 changes: 49 additions & 49 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,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 @@ -237,16 +237,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 @@ -389,7 +389,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 @@ -409,7 +409,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 @@ -492,7 +492,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 @@ -548,7 +548,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 @@ -578,7 +578,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 @@ -655,7 +655,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 @@ -667,7 +667,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 @@ -916,7 +916,7 @@ Schema.prototype._hasEncryptedFields = function _hasEncryptedFields() {
return Object.keys(this.encryptedFields).length > 0;
};

Schema.prototype._buildEncryptedFields = function () {
Schema.prototype._buildEncryptedFields = function() {
const fields = Object.entries(this.encryptedFields).map(
([path, config]) => {
const bsonType = inferBSONType(this, path);
Expand All @@ -927,7 +927,7 @@ Schema.prototype._buildEncryptedFields = function () {
return { fields };
};

Schema.prototype._buildSchemaMap = function () {
Schema.prototype._buildSchemaMap = function() {
/**
* `schemaMap`s are JSON schemas, which use the following structure to represent objects:
* { field: { bsonType: 'object', properties: { ... } } }
Expand Down Expand Up @@ -1189,7 +1189,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 @@ -1490,7 +1490,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 @@ -1765,7 +1765,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 @@ -1846,7 +1846,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 @@ -1889,7 +1889,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 @@ -1909,7 +1909,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 @@ -2007,7 +2007,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 @@ -2055,7 +2055,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 @@ -2111,7 +2111,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 @@ -2154,7 +2154,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 @@ -2209,7 +2209,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 @@ -2255,7 +2255,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 @@ -2280,7 +2280,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 @@ -2326,7 +2326,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 @@ -2417,7 +2417,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 @@ -2433,10 +2433,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 @@ -2471,7 +2471,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 @@ -2491,7 +2491,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 @@ -2553,7 +2553,7 @@ Schema.prototype.virtual = function (name, options) {
});

virtual.
set(function (v) {
set(function(v) {
if (!this.$$populatedVirtuals) {
this.$$populatedVirtuals = {};
}
Expand Down Expand Up @@ -2599,7 +2599,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 @@ -2625,7 +2625,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 @@ -2649,12 +2649,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 @@ -2708,7 +2708,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 @@ -2770,7 +2770,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 @@ -2783,7 +2783,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 @@ -2795,7 +2795,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 @@ -2826,7 +2826,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 @@ -2933,7 +2933,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 @@ -2943,8 +2943,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 57e548b

Please sign in to comment.