diff --git a/lib/mongo/extendMongoCollection.js b/lib/mongo/extendMongoCollection.js index fed359f9..66a0729a 100644 --- a/lib/mongo/extendMongoCollection.js +++ b/lib/mongo/extendMongoCollection.js @@ -1,98 +1,98 @@ -import { Mongo } from 'meteor/mongo' -import { _ } from 'meteor/underscore' -import _validatedInsert from './allow-deny/validatedInsert' -import _validatedUpdate from './allow-deny/validatedUpdate' -import _validatedRemove from './allow-deny/validatedRemove' -import Mutator from './Mutator' -import extendObserveChanges from './extendObserveChanges' -import { Meteor } from 'meteor/meteor' +import { Mongo } from 'meteor/mongo'; +import { _ } from 'meteor/underscore'; +import _validatedInsertAsync from './allow-deny/validatedInsert'; +import _validatedUpdateAsync from './allow-deny/validatedUpdate'; +import _validatedRemoveAsync from './allow-deny/validatedRemove'; +import Mutator from './Mutator'; +import extendObserveChanges from './extendObserveChanges'; +import { Meteor } from 'meteor/meteor'; export default () => { - const Originals = { - insertAsync: Mongo.Collection.prototype.insertAsync, - updateAsync: Mongo.Collection.prototype.updateAsync, - removeAsync: Mongo.Collection.prototype.removeAsync, - find: Mongo.Collection.prototype.find, - findOneAsync: Mongo.Collection.prototype.findOneAsync - } + const Originals = { + insertAsync: Mongo.Collection.prototype.insertAsync, + updateAsync: Mongo.Collection.prototype.updateAsync, + removeAsync: Mongo.Collection.prototype.removeAsync, + find: Mongo.Collection.prototype.find, + findOneAsync: Mongo.Collection.prototype.findOneAsync, + }; - Mutator.init() + Mutator.init(); - extendObserveChanges() + extendObserveChanges(); - Object.assign(Mongo.Collection.prototype, { - /** + Object.assign(Mongo.Collection.prototype, { + /** * @param data * @param config * @returns {*} */ - insertAsync (data, config) { - return Mutator.insert.call(this, Originals, data, config) - }, + insertAsync(data, config) { + return Mutator.insert.call(this, Originals, data, config); + }, - /** + /** * @param selector * @param modifier * @param config * @param callback * @returns {*} */ - updateAsync (selector, modifier, config, callback) { - return Mutator.update.call( - this, - Originals, - selector, - modifier, - config, - callback - ) - }, + updateAsync(selector, modifier, config, callback) { + return Mutator.update.call( + this, + Originals, + selector, + modifier, + config, + callback, + ); + }, - /** + /** * @param selector * @param config * @returns {*} */ - removeAsync (selector, config) { - return Mutator.remove.call(this, Originals, selector, config) - }, + removeAsync(selector, config) { + return Mutator.remove.call(this, Originals, selector, config); + }, - _validatedInsert, - _validatedUpdate, - _validatedRemove, + _validatedInsertAsync, + _validatedUpdateAsync, + _validatedRemoveAsync, - /** + /** * Configure defaults for your collection * * @param {function} mutation * @param {function} cursor * @param {boolean} shouldIncludePrevDocument */ - configureRedisOplog ({ mutation, cursor, ...rest }) { - this._redisOplog = { - shouldIncludePrevDocument: false, - protectAgainstRaceConditions: true, - ...rest - } + configureRedisOplog({ mutation, cursor, ...rest }) { + this._redisOplog = { + shouldIncludePrevDocument: false, + protectAgainstRaceConditions: true, + ...rest, + }; - if (mutation) { - if (!_.isFunction(mutation)) { - throw new Meteor.Error( - 'To configure defaults for the collection, "mutation" needs to be a function' - ) - } + if (mutation) { + if (!_.isFunction(mutation)) { + throw new Meteor.Error( + 'To configure defaults for the collection, "mutation" needs to be a function', + ); + } - this._redisOplog.mutation = mutation - } - if (cursor) { - if (!_.isFunction(cursor)) { - throw new Meteor.Error( - 'To configure defaults for the collection, "cursor" needs to be a function' - ) - } + this._redisOplog.mutation = mutation; + } + if (cursor) { + if (!_.isFunction(cursor)) { + throw new Meteor.Error( + 'To configure defaults for the collection, "cursor" needs to be a function', + ); + } - this._redisOplog.cursor = cursor - } - } - }) + this._redisOplog.cursor = cursor; + } + }, + }); }