【问题标题】:Output / show / print Meteor Simple Schema of Entities输出/显示/打印 Meteor 实体的简单模式
【发布时间】:2018-10-19 10:31:29
【问题描述】:

我有一个 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 ) 的函数输出所有已定义的属性/字段及其数据类型?

【问题讨论】:

    标签: json mongodb meteor simple-schema meteor-collections


    【解决方案1】:

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

    例如

    Template.xyz.onRendered(function(){
      console.log(Cards._c2._simpleSchema);
    });
    

    【讨论】:

    • _c2 的目的是什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-08
    • 1970-01-01
    • 2014-09-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多