0

我有一个 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;
      }
    },
  },

等等。

是否有类似的功能:log( Cards.schema )输出所有定义的属性/字段及其数据类型?

4

1 回答 1

0

是的!您可以在客户端,在您订阅Cards集合的地方执行以下操作。

例如

Template.xyz.onRendered(function(){
  console.log(Cards._c2._simpleSchema);
});
于 2018-05-09T11:38:46.493 回答