Hello everyone,
I’m trying to make an complete application with the ‘todos’ skeleton (https://github.com/meteor/todos/).
In my API file, I have an error with helpers declaration… Could you help me ?
Error :
W20170420-10:10:54.101(2)? (STDERR) TypeError: Equipments.helpers is not a function
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { Factory } from 'meteor/dburles:factory';
import faker from 'faker';
import { EquipmentSchema } from './schema';
faker.locale = 'fr';
export const Equipments = new Mongo.Collection('equipments');
export default 'Equipments';
// Deny all client-side updates since we will using methods
Equipments.deny({
insert() { return true; },
update() { return true; },
remove() { return true; },
});
// Associate the schema for checking values
Equipments.schema = EquipmentSchema;
Equipments.attachSchema(Equipments.schema);
// Public fields (published to the client)
Equipments.publicFields = {
name: 1,
number: 1,
part: 1,
active: 1,
cron: 1,
workshops: 1,
connection: 1,
settings: 1,
informations: 1,
state: 1,
};
// Factory for tests
Factory.define('equipment', Equipments, {
name: () => faker.lorem.word(),
number: () => faker.random.number(),
part: () => faker.hacker.noun(),
active: true,
cron: () => faker.random.number(),
workshops: () => [faker.commerce.department()],
connection: {
ip: () => faker.internet.ip.toString(),
},
});
// Helpers
Equipments.helpers({
visibleBy(userId) {
if (this.workshop.length === 0) {
return true;
}
const currentUser = Meteor.users.findOne(userId);
return (_.intersection(currentUser.whorkshops.white, this.wrokshops).length > 0 &&
_.intersection(currentUser.whorkshops.black, this.workshops).length === 0);
},
isActive() {
return this.active;
},
});
Resolved :
I have forgotten to add dburles:collection-helpers package…