Hi,
I’m currently trying to insert a record using astronomy into a collection. Any thoughts on what i should be importing. Here is my current import list on Methods.js
import {Meteor} from 'meteor/meteor';
import {Mongo} from 'meteor/mongo';
import {coupons, coupon} from '/lib/collection.jsx'
The method
'addCoupon': function(name, redeems, couponType, startDate) {
var coupon = new coupon();
coupon.set({
name: name,
code: name,
redeemsAllowed: redeems,
couponType: couponType,
startDate: startDate,
endDate: startDate
});
coupon.save(); // Document insertion.
}
and collection.jsx
import {Meteor} from 'meteor/meteor';
import {Accounts} from 'meteor/accounts-base';
import {Mongo} from 'meteor/mongo';
import {Astro} from 'meteor/jagi:astronomy';
import {Validators} from 'meteor/jagi:astronomy-validators';
import {relations} from 'meteor/jagi:astronomy-relations';
import {timestamp} from 'meteor/jagi:astronomy-timestamp-behavior';
export const coupons = new Mongo.Collection('coupons');
…
export const coupon = Astro.Class({
name: 'Coupons',
collection: coupons,
fields: {
'name': {
type: 'string'
},
'code': {
type: 'string'
},
'redeemsAllowed': {
type: 'number'
},
'redeemsLeft': {
type: 'number',
optional: true,
transient: true
},
'redeemers': {
type: 'array',
optional: true,
nested: 'Redeemers',
default: function() {
return [];
}
},
'couponType': {
type: 'string'
// CAN BE TYPE USER, COMPANY, GLOBAL
},
'restrictions': {
type: 'array',
optional: true
},
'startDate': {
type: 'date'
},
'endDate': {
type: 'date'
}
},
'events': {
beforeFind: function() {
this.set('redeemsLeft', this.redeemsAllowed - this.redeemers.length);
}
}
})
Thank you in advance for any help that can be provided.