this.validate({
fields: ['name']
}, (err) => {
if (ValidationError.is(err)) {
throw new Meteor.Error();
} else {
return this.save();
}
save();
Exception while invoking method '/Astronomy/execute' TypeError: Class is not a constructor
I20171103-20:10:21.932(2)? at DDPCommon.MethodInvocation.astronomyExecute (packages/jagi:astronomy/lib/modules/methods/meteor_methods/astronomyExecute.js:22:11)
I20171103-20:10:21.933(2)? at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1768:12)
I20171103-20:10:21.933(2)? at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
I20171103-20:10:21.933(2)? at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1134:15)
I20171103-20:10:21.934(2)? at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
I20171103-20:10:21.934(2)? at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1134:15)
I20171103-20:10:21.934(2)? at Promise (packages/ddp-server/livedata_server.js:715:46)
I20171103-20:10:21.934(2)? at new Promise (<anonymous>)
I20171103-20:10:21.934(2)? at Session.method (packages/ddp-server/livedata_server.js:689:23)
I20171103-20:10:21.934(2)? at packages/ddp-server/livedata_server.js:559:43
import '../imports/api/classes/Customer';
import '../imports/api/classes/Brand';
// In your schema definition, add event beforeInsert:
events: {
beforeInsert(e) {
const latest = XXX.findOne({}, {
sort: { YYY: -1 },
});
e.currentTarget.YYY = (typeof latest === 'undefined') ? 1 : latest.YYY + 1;
},
},
...
import MongoCounters from 'mongodb-counter';
// Setup the counters object used for auto-incrementing
const path = `${process.env.PWD}/pm2-meteor.json`;
const json = fs.readFileSync(path, 'utf8');
const config = JSON.parse(json);
const counters = MongoCounters.createCounters({
mongoUrl: config.env.MONGO_URL
});
const Invoice = Class.create({
...
events: {
beforeInsert(e) {
const invoice = e.currentTarget;
// Wrap the counters increment and get method so they're
// synchronous. I tried to use the callback methods as
// in the docs for mongo-counter, but it didnt work
Meteor.wrapAsync(counters('invoiceId').increment)();
const nextId = Meteor.wrapAsync(counters('invoiceId').get)();
if (typeof nextId === 'number') {
invoice.invoiceId = nextId;
}
}
},
...
// Define FileStatus enum.
const FileStatus = Enum.create({
name: 'FileStatus',
identifiers: ['TEMPORARY', 'PERMANENT'],
});
// Inside schema definition.
status: {
type: FileStatus,
default: FileStatus.TEMPORARY,
},