[英]Output / show / print Meteor Simple Schema of Entities
I have a Meteor app and generated some DB Collections which have a SimpleSchema https://github.com/aldeed/simple-schema-js attached. 我有一个Meteor应用程序,并生成了一些附加了SimpleSchema https://github.com/aldeed/simple-schema-js的数据库集合。
Cards = new Mongo.Collection('cards');
Cards.attachSchema(new SimpleSchema({
title: {
type: String,
},
archived: {
type: Boolean,
autoValue() {
if (this.isInsert && !this.isSet) {
return false;
}
},
},
completed: {
type: Boolean,
autoValue() {
if (this.isInsert && !this.isSet) {
return false;
}
},
},
And so on. 等等。
Is there a function something like: log( Cards.schema )
which outputs all the defined properties / fields and their datatypes? 是否有类似函数:
log( Cards.schema )
输出所有已定义的属性/字段及其数据类型?
Yes! 是! you can do as below at the client side , at the place you have subscribed the
Cards
collection. 您可以在预订
Cards
集合的客户处在客户端执行以下操作。
eg 例如
Template.xyz.onRendered(function(){
console.log(Cards._c2._simpleSchema);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.