diff --git a/collections.js b/collections.js index 929ccd5..28ce4eb 100644 --- a/collections.js +++ b/collections.js @@ -1,14 +1,14 @@ -import { Meteor } from "meteor/meteor"; -import { Mongo } from "meteor/mongo"; +import { Meteor } from 'meteor/meteor'; +import { Mongo } from 'meteor/mongo'; -import { getSettings } from "meteor/quave:settings"; +import { getSettings } from 'meteor/quave:settings'; // to load helpers -import "./helpers"; +import './helpers'; // to load attachSchema -import "./schema"; +import './schema'; -const PACKAGE_NAME = "quave:collections"; +const PACKAGE_NAME = 'quave:collections'; const settings = getSettings({ packageName: PACKAGE_NAME }); const { isServerOnly, isVerbose } = settings; @@ -23,7 +23,7 @@ const compose = (...funcs) => (a, b) => (...args) => a(b(...args)), - (arg) => arg, + (arg) => arg ); const getDbCollection = ({ name, helpers, instance, options }) => { @@ -54,12 +54,12 @@ export const createCollection = ({ if (!name && !instance) { throw new Error( - "The option 'name' is required, unless you are using the option 'instance' that is not your case :).", + "The option 'name' is required, unless you are using the option 'instance' that is not your case :)." ); } if (Meteor.isClient && isServerOnly) { throw new Error( - "Collections are not allowed in the client, you can disable this changing the setting `isServerOnly`", + 'Collections are not allowed in the client, you can disable this changing the setting `isServerOnly`' ); } const dbCollection = getDbCollection({ @@ -82,9 +82,9 @@ export const createCollection = ({ } catch (e) { console.error( `An error has happened when your collection${ - name ? ` "${name}"` : "" + name ? ` "${name}"` : '' } was being created.`, - e, + e ); throw e; } diff --git a/helpers-test.js b/helpers-test.js index 761fa8f..682df33 100644 --- a/helpers-test.js +++ b/helpers-test.js @@ -1,28 +1,28 @@ -import { Mongo } from "meteor/mongo"; +import { Mongo } from 'meteor/mongo'; const options = { _suppressSameNameError: true }; -Tinytest.addAsync("works", async function (test) { +Tinytest.addAsync('works', async function (test) { const Books = new Mongo.Collection(`books`, options); const Authors = new Mongo.Collection(`authors`, options); const author1 = await Authors.insertAsync({ - firstName: "Charles", - lastName: "Darwin", + firstName: 'Charles', + lastName: 'Darwin', }); const author2 = await Authors.insertAsync({ - firstName: "Carl", - lastName: "Sagan", + firstName: 'Carl', + lastName: 'Sagan', }); const book1 = await Books.insertAsync({ authorId: author1, - name: "On the Origin of Species", + name: 'On the Origin of Species', }); const book2 = await Books.insertAsync({ authorId: author2, - name: "Contact", + name: 'Contact', }); Books.helpers({ @@ -33,7 +33,7 @@ Tinytest.addAsync("works", async function (test) { // We should be able to apply more if we wish Books.helpers({ - foo: "bar", + foo: 'bar', }); Authors.helpers({ @@ -48,12 +48,12 @@ Tinytest.addAsync("works", async function (test) { const bookFirst = await Books.findOneAsync(book1); const authorFirst = await bookFirst?.author(); - test.equal(authorFirst?.firstName, "Charles"); - test.equal(bookFirst?.foo, "bar"); + test.equal(authorFirst?.firstName, 'Charles'); + test.equal(bookFirst?.foo, 'bar'); const bookSecond = await Books.findOneAsync(book2); const authorSecond = await bookSecond?.author(); - test.equal(authorSecond?.fullName(), "Carl Sagan"); + test.equal(authorSecond?.fullName(), 'Carl Sagan'); const authorThird = await Authors.findOneAsync(author1); const booksThird = await authorThird?.books(); @@ -61,13 +61,13 @@ Tinytest.addAsync("works", async function (test) { }); Tinytest.addAsync( - "throw error if transform function already exists", + 'throw error if transform function already exists', async function (test) { const Author = function (doc) { return Object.assign(this, doc); }; - Author.prototype.fullName = "Charles Darwin"; + Author.prototype.fullName = 'Charles Darwin'; const Authors = new Mongo.Collection(`authors`, { ...options, @@ -83,5 +83,5 @@ Tinytest.addAsync( }, }); }); - }, + } ); diff --git a/helpers.js b/helpers.js index 4360a0a..a2e1d6f 100644 --- a/helpers.js +++ b/helpers.js @@ -3,7 +3,7 @@ Mongo.Collection.prototype.helpers = function (helpers) { if (self._transform && !self._helpers) { throw new Meteor.Error( - `Can't apply helpers to '${self._name}' a transform function already exists!`, + `Can't apply helpers to '${self._name}' a transform function already exists!` ); } diff --git a/package.js b/package.js index 408a94e..941514d 100644 --- a/package.js +++ b/package.js @@ -11,14 +11,14 @@ Npm.depends({ 'lodash.isobject': '3.0.2', }); -Package.onUse(function(api) { +Package.onUse(function (api) { api.versionsFrom('METEOR@3.0-alpha.18'); api.use([ 'ecmascript@0.16.7||0.16.8-alpha300.18', 'mongo@1.0.0||2.0.0||2.0.0-alpha300.17', 'minimongo@1.9.3||2.0.0-alpha300.18', - 'ejson@1.1.3||1.1.4-alpha300.18' + 'ejson@1.1.3||1.1.4-alpha300.18', ]); api.imply('mongo'); @@ -30,13 +30,8 @@ Package.onUse(function(api) { api.mainModule('collections.js'); }); -Package.onTest(function(api) { - api.use([ - 'ecmascript', - 'tinytest', - 'insecure', - 'autopublish', - 'mongo']); +Package.onTest(function (api) { + api.use(['ecmascript', 'tinytest', 'insecure', 'autopublish', 'mongo']); api.addFiles(['helpers.js', 'helpers-test.js']); });