当前位置: 动力学知识库 > 问答 > 编程问答 >

Meteor autoform and Collection2 not saving data

问题描述:

I am having problems with Collection2 and autoform. Here is my collection

Customers = new Mongo.Collection("customers");

Customers.allow({insert: function(userId, doc) {return !!userId;}

});

CustomerSchema = new SimpleSchema({name: {type: String,label: "Name"},address: {type: String,label: "Address"},amount: {type: Number,label: "Amount"},bvn: {type: String,label: "BVN"},type: {type: String,label: "Sale Type"},saleDate: {type: Date,label: "Transaction Date",autoValue: function() {return new Date()},autoform: {type: "hidden"}},passport: {type: String,label: "Passport Number"},source: {type: String,label: "Source"},tickets: {type: Boolean,label: "Tickets"},visa: {type: Boolean,label: "Visa"},invoice: {type: Boolean,label: "Invoice"},nextSaleDate: {type: Date,label: "Next Sale Date",autoValue: function () {var thisDate = new Date();var dd = thisDate.getDate();var mm = thisDate.getMonth() + 3;var y = thisDate.getFullYear();var nextDate = dd + '/'+ mm + '/'+ y;return nextDate;},autoform: {type: "hidden"}},author: {type: String,label: "Author",autoValue: function () {return this.userId},autoform: {type: "hidden"}}

});

Customers.attachSchema(CustomerSchema);

网友答案:

I sorted it out. This field in the collection

nextSaleDate: {type: Date,label: "Next Sale Date",autoValue: function () {var thisDate = new Date();var dd = thisDate.getDate();var mm = thisDate.getMonth() + 3;var y = thisDate.getFullYear();var nextDate = dd + '/'+ mm + '/'+ y;return nextDate;},autoform: {type: "hidden"}},
分享给朋友:
您可能感兴趣的文章:
随机阅读: