Hello,
I spent all my afternoon for this thing… :’(
I try to realize methods.js file, according to “todos” example.
I have many erros on Invalid definition for equipmentUpdated field. and ValidateMethod is not a function. …
Could you help me ?
import { Meteor } from 'meteor/meteor';
import { ValidateMethod } from 'meteor/mdg:validated-method';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { Equipments } from './equipments';
const EQUIPMENT_ID_ONLY = new SimpleSchema({
_id: Equipments.simpleSchema().schema('_id'),
}).validator({ clean: true, filtre: false });
export const update = new ValidateMethod({
name: 'equipments.update',
validate: new SimpleSchema({
equipmentId: Equipments.simpleSchema().schema('_id'),
equipmentUpdated: Equipments.simpleSchema().schema(),
}).validator({ clean: true, filter: false }),
run({ equipmentId, equipmentUpdated }) {
if (!this.userId) {
throw new Meteor.Error('equipments.insert.not-logged-in', 'Must be logged in to create invoice.');
}
Equipments.update(equipmentId, _.omit(equipmentUpdated, '_id'), { validate: false });
},
});
Many thanks :’)