0

我遇到了 Collection2 和 autoform 的问题。这是我的收藏

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);

我已经在单独的发布和订阅 javascript 文件中分别发布和订阅了这些Meteor.publish('customers', function() { return Customers.find({author: this.userId}); });集合Meteor.subscribe("customers");。这是插入的html代码

<template name="NewCustomer">
	<div class="new-customer">
		{{>quickForm collection="Customers" id="insertCustomerForm" type="insert" class="new-customer-form"}}
	</div>
</template>

但是当我启动服务器并添加新客户时,它不起作用。谁能帮我吗?谢谢

4

1 回答 1

0

我整理了一下。集合中的这个字段

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"
		}
	},

是导致问题的原因。谢谢大家的意见

于 2015-12-30T23:36:45.890 回答