[英]how to get date from a form submission
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? 如何更改此代码以获取测试通过日期而不是当前日期?
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. 我需要获取证书ID,然后获取证书,然后才能获取数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.