diff --git a/package/collection2/lib.js b/package/collection2/lib.js index cade2b8..2ffb3b7 100644 --- a/package/collection2/lib.js +++ b/package/collection2/lib.js @@ -10,7 +10,7 @@ export function flattenSelector(selector) { const obj = {}; - Object.entries(selector).forEach(([key, value]) => { + for (const [key, value] of Object.entries(selector) || []) { // Ignoring logical selectors (https://docs.mongodb.com/manual/reference/operator/query/#logical) if (!key.startsWith('$')) { if (typeof value === 'object' && value !== null) { @@ -25,7 +25,7 @@ export function flattenSelector(selector) { obj[key] = value; } } - }); + } return obj; } diff --git a/package/collection2/main.js b/package/collection2/main.js index d97041e..8d712df 100644 --- a/package/collection2/main.js +++ b/package/collection2/main.js @@ -117,7 +117,7 @@ Mongo.Collection.prototype.attachSchema = function c2AttachSchema(ss, options) { Collection2.emit('schema.attached', this, ss, options); }; - [Mongo.Collection, LocalCollection].forEach((obj) => { + for (const obj of [Mongo.Collection, LocalCollection]) { /** * simpleSchema * @description function detect the correct schema by given params. If it @@ -132,7 +132,7 @@ Mongo.Collection.prototype.attachSchema = function c2AttachSchema(ss, options) { obj.prototype.simpleSchema = function (doc, options, query) { if (!this._c2) return null; if (this._c2._simpleSchema) return this._c2._simpleSchema; - + const schemas = this._c2._simpleSchemas; if (schemas && schemas.length > 0) { let schema, selector, target; @@ -140,7 +140,7 @@ Mongo.Collection.prototype.attachSchema = function c2AttachSchema(ss, options) { for (let i = 1; i < schemas.length; i++) { schema = schemas[i]; selector = Object.keys(schema.selector)[0]; - + // We will set this to undefined because in theory, you might want to select // on a null value. target = undefined; @@ -156,7 +156,7 @@ Mongo.Collection.prototype.attachSchema = function c2AttachSchema(ss, options) { // on upsert/update operations target = query[selector]; } - + // we need to compare given selector with doc property or option to // find the right schema if (target !== undefined && target === schema.selector[selector]) { @@ -169,12 +169,12 @@ Mongo.Collection.prototype.attachSchema = function c2AttachSchema(ss, options) { throw new Error('No default schema'); } } - + return null; }; - }); + } - function getArgumentsAndValidationContext(methodName, args, async) { +function getArgumentsAndValidationContext(methodName, args, async) { let options = isInsertType(methodName) ? args[1] : args[2]; // Support missing options arg @@ -414,14 +414,12 @@ Mongo.Collection.prototype.attachSchema = function c2AttachSchema(ss, options) { }; const cleanOptionsForThisOperation = {}; - ['autoConvert', 'filter', 'removeEmptyStrings', 'removeNullsFromArrays', 'trimStrings'].forEach( - (prop) => { - if (typeof options[prop] === 'boolean') { - cleanOptionsForThisOperation[prop] = options[prop]; - } + for (const prop of ['autoConvert', 'filter', 'removeEmptyStrings', 'removeNullsFromArrays', 'trimStrings']) { + if (typeof options[prop] === 'boolean') { + cleanOptionsForThisOperation[prop] = options[prop]; } - ); - + } + // Preliminary cleaning on both client and server. On the server and for local // collections, automatic values will also be set at this point. schema.clean(doc, { diff --git a/package/collection2/package.js b/package/collection2/package.js index 3826f7e..022971b 100644 --- a/package/collection2/package.js +++ b/package/collection2/package.js @@ -4,7 +4,7 @@ Package.describe({ name: 'aldeed:collection2', summary: 'Automatic validation of Meteor Mongo insert and update operations on the client and server', - version: '4.0.3', + version: '4.0.4', documentation: '../../README.md', git: 'https://github.com/aldeed/meteor-collection2.git' }); @@ -23,7 +23,7 @@ Package.onUse(function (api) { api.use('ejson'); api.use('ecmascript'); api.use('raix:eventemitter@1.0.0'); - api.use('aldeed:simple-schema@1.13.1 || 2.0.0-rc.300.10'); + api.use('aldeed:simple-schema@1.13.1 || 2.0.0-rc300.1'); api.addFiles(['./collection2.js']);