Reputation: 15
I'm working on a class app in meteor that you take the class then take a test. If you pass the test, you get a certificate. I am having issues with getting the pass date on the certificate.
import moment from 'moment';
Template.SingleCertificate.helpers({
passDate: function(){
const id = FlowRouter.getParam('id');
const classC = ClassC.findOne({_id:id});
}
});
export const ClassC = new Mongo.Collection('classc');
ClassCSchema = new SimpleSchema({
passDate: {
type: Date,
optional: true
}
This code displays the current date and not the date the test was passed. The date is stored in the DB in the collection (schema). How can I change this code to retrieve the tests pass date instead of the current date?
Upvotes: 0
Views: 115
Reputation: 15
I figured out the answer:
passDate: function(){
const id = FlowRouter.getParam('id');
const certificate = ClassC.findOne({_id:id});
const passDate = certificate.passDate;
return moment(passDate).format('MM/DD/YYYY');
}
I needed to get the certificate ID, then the certificate, then I could get to the data.
Upvotes: 0